A New York man who police say smuggled a gun into a Vermont State Police holding cell was ordered held on $500,000 bail Friday on a number of drug and weapon offenses.

Cuwan I. Merritt was frisked by police twice Thursday — once on the side of Route 7 where the car he was riding in was stopped and again at the Vermont State Police barracks in Shaftsbury, according to an affidavit filed by Trooper Lewis Hatch.

But the pat downs failed to reveal a .380-caliber handgun with four rounds in the magazine that Hatch said police found Merritt trying to hide in a holding cell where he was being detained while police applied for a warrant to search him.

Also on the 24-year-old’s person, police said, was 37.96 grams of heroin divided into 1,190 bindles or individual doses. That amount of heroin has a street value of roughly $3,800, according to police in Rutland County, and was more than 10 times the 3.5 grams of the drug required for prosecutors to bring a charge of trafficking — the highest drug offense in the state, which carries a potential 30-year jail sentence.

Merritt, of Kings County, N.Y., pleaded innocent Friday in Rutland criminal court to one count of heroin trafficking along with a felony charge of possessing the drug and another felony charge of carrying a deadly weapon while committing a felony.

A fourth felony charge was brought against him for allegedly stealing the identify of another New York man who Merritt allegedly posed as while using a fake identification.

Merritt also entered a denial for a parole violation filed against him in New York where he was recently convicted on a robbery charge, according to court records.

Merritt’s court-appointed public defender didn’t argue against the $500,000 sought by a Bennington County prosecutor.

Police say Merritt was riding in the back seat of a car stopped traveling north on Route 7 on Thursday afternoon in Dorset near the Rutland County line.

After stopping the car for allegedly speeding in the 45-mph zone, Hatch said he began to suspect illegal activity based on the actions and statements made by the driver, Stephanie L. Socia, 23, Merritt and another passenger.

After Socia granted the trooper permission to search the vehicle, a drug-sniffing police canine was brought to the scene and gave positive responses for the presence of narcotics, Hatch said.

Hatch said he also came across a phone in the back seat that contained a text message exchange that read “They aren’t searching or anything are they” followed by “They’re trying to, mad (expletive) in the car too.”

After Suboxone pills, prescribed for the treatment of opiate addictions, were found in Socia’s purse she was arrested and later released on a citation to appear in court.

Merritt, who refused to grant consent for a search of his person, was taken to the Shaftsbury barracks where police were preparing to apply for a warrant to search him when Merritt was allegedly caught trying to hide the gun and heroin in a blanket.