LEWISTON — A Lewiston man who led police to a mosque where he was found in his underwear was sentenced Wednesday in federal court to 15 years in prison for having a gun illegally.

Kaya Simions, 23, pleaded guilty to a charge of possession of a firearm by a felon or a so-called armed career criminal.

Simions was convicted of five violent felonies between 2006 and 2008, four of them in Massachusetts, court records showed. His convictions include assault and battery on a police officer, breaking and entering and battery on a public employee.

According to court records, Simions shot a handgun on Aug. 4 into the air twice on Oak Street in Lewiston. Police saw a person matching his description fleeing the scene. Police chased him on foot, watching as he held something in front of his pants. He ran into some bushes, then jumped a fence. He shed clothing as he ran, leaving a trail to a local mosque. He was found at the mosque wearing only his underwear.

Police found the handgun along with Simions’ discarded clothing in the bushes. The .38 caliber Colt Cobra had four live rounds and two spent shell casings, court records showed.

A federal prosecutor wrote that the gun was traced to one that was stolen during a residential burglary in Lewiston on Jan. 23, 2009. Simions wasn’t implicated in that burglary, according to Assistant U.S. Attorney Darcie McElwee.

After his arrest, Simions told police, “You know I did it. I ain’t getting out of this.”

After serving his prison sentence, Simions will be on supervised release for five years, according to court records.

During his release, Simions can’t have a firearm or any other dangerous weapon. He also must participate in mental health treatment and comply with a medication program prescribed by a medical practitioner.

Simions is barred from having and using alcohol or illegal drugs and must participate in drug and alcohol abuse therapy counseling.