BARNSTABLE — A Hyannis man pleaded not guilty Thursday in Barnstable District Court to drug trafficking charges after police allegedly found fentanyl, cocaine and a handgun in a Jeep Grand Cherokee during a search of his home and the vehicle the week before.

On Oct. 15, police obtained a search warrant for the house at 19 Dartmouth St. after a two-month investigation, including undercover buys, according to a police report. During the search the next day, police did not locate Jamarcus Williams, 30, but they did find 144 grams of fentanyl, 18 grams of cocaine, a semi-automatic handgun and ammunition in a Jeep registered in the name of Williams' girlfriend but which she said he drove exclusively, the report says. There is no indication in the report that anyone else at the house at the time of the search was arrested.

Previous drug convictions would prohibit Williams from having a license to carry a firearm, according to the report. Police sought and received a warrant for Williams' arrest, which occurred during a traffic stop early Thursday morning near Exit 4 on Route 6 westbound.

A state trooper pulled over a vehicle driven by Luis Hernandez, 29, of Wareham, in which Williams was a passenger, after it drifted over a "fog line" and was clocked doing 40 mph in a 55 mph zone, according to another police report. Police found a large amount of marijuana and $2,577 in cash in the vehicle, the report says.

Williams was charged with possession of marijuana with intent to distribute based on the traffic stop. He was charged with trafficking more than 10 grams of fentanyl; possession of a firearm without a license; possession of a class B drug with intent to distribute, subsequent offense; and possession of ammunition without an FID card.

He was ordered held on $100,000 bail in connection with the marijuana charge and $150,000 for the other charges, based on his financial resources, nature and circumstances of the charges against him, the potential penalty he faces, his record of convictions and his drug dependency or record of illegal drug distribution, according to court documents.

A pretrial hearing in the case is scheduled for Nov. 13.

Hernandez pleaded not guilty Thursday to charges of driving with revoked license and marked lanes violation. He was released on personal recognizance. A pretrial hearing is scheduled for Dec. 14.