A masked raider was sprayed with CS gas as police foiled a bungled attempt to steal thousands of pounds worth of alcohol and cigarettes from Somerfield, in Malmesbury.

Two thieves stacked crates of whiskey and vodka, DVD players and cartons of cigarettes by a fire exit in the store. Their getaway car, a stolen Rover Metro, was parked by the landing bay at the back of the Gloucester Road store.

But they were surprised by police officers before they had time to load the car with their booty.

As they attempted to escape they ran at the officers, one of whom discharged his CS gas canister into the face of one of the raiders, later identified as Martin Lockey.

The 23-year-old, of no fixed abode, pleaded guilty at Chippenham Magistrates' Court on Monday to charges of trespassing at the Malmesbury supermarket with intention to steal.

Prosecuting, Emmalyne Downing said two police officers and store staff congregated at the store when its alarm was set off at 3.46am on Saturday.

The officers found the car parked at the back of the store, which they discovered was stolen from Swindon on December 23.

One of the thieves poked his head around the door of a fire exit, located near the car, saw the police officers and slammed the door shut. The court heard that the officers were unable to pursue the man because the exit only opened from the inside.

Minutes later the officers heard banging from another fire exit and two masked men shot out of the door and ran straight at the officers.

One was sprayed in the face with CS gas and was captured five minutes later, but the other robber escaped.

Police discovered three cases of Bells Whiskey worth £300, two cases of Smirnoff vodka, four storage containers crammed with cigarettes .

The haul was worth a total of £2,000 and a £38 DVD player neatly stacked near the rear fire exit.

They also found that the store's CCTV tape had been removed from its machine, which was in the main office.

The court heard that at his interview with the police Lockey claimed he bumped into a friend, who he would not name, driving a red Metro, at 1am on Saturday.

He agreed to go for a smoke with his friend and got into the car's passenger seat.

They drove to Malmesbury, where Lockey said he had never been before.

They entered the store's car park, where Lockey went to the toilet, while his friend broke into the store.

The court heard that he admitted following his friend into the store with the intention of stealing.

Defending Phillip Hall said his client also pleaded guilty to stealing £100 of perfume from a chemist's shop in Oxfordshire only a few months earlier. He urged Chippenham Magistrates to combine the matters so they could be dealt with together.

The case was adjourned until January 19 to allow the probation service to draw up an all options report for sentencing.

Lockey was remanded in custody.

A spokesman for Wiltshire police said: "Police officers do carry CS spray at all times and it enables officers who are faced with violence to control individuals with the minimum of force.

"Normally there will be improved safety not just for officers but the individuals concerned.

"Officers are trained to use the spray and are retested every year."