BOSTON — A man charged with having once possessed the gun that prosecutors believe the Boston Marathon bombing suspects used to kill an MIT police officer pleaded guilty Friday to gun possession and drug charges.

Stephen Silva, 21, changed his plea in U.S. District Court. He initially pleaded innocent after he was charged in July with possession of a handgun with an obliterated serial number and seven counts of heroin trafficking.

Silva was a friend of marathon bombing suspect Dzhokhar Tsarnaev, who faces trial in January in connection with the April 2013 attack that killed three people and injured more than 260 others.

A prosecutor said Silva possessed the Ruger pistol in February 2013, and gave it to another individual. That person was not identified in court and no reference was made to the bombing or the fatal shooting of Massachusetts Institute of Technology police officer Sean Collier several days after the attack.

“He has not been charged with having anything to do with the marathon bombing (or) having any knowledge that the gun, if it were used, was used in connection with the bombing or the aftermath,” said Silva’s lawyer, Jonathan Shapiro, after Friday’s hearing.

Shapiro had confirmed earlier that authorities believed the gun was the one Tsarnaev and his older brother Tamerlan used to kill Collier, who was shot in his cruiser in Cambridge during the massive manhunt following the bombing attack.