A Mississippi man has found himself locked up and facing federal charges for possessing guns that police officials returned to him following a court order.

Stephen Drew Montana, 26, of Biloxi, is charged with possession of weapons after being committed to a mental institution. His attorney is demanding that the charges be dropped, arguing that “outrageous government conduct” caused the crime.

The Sun Herald in Biloxi reported that Montana's AK-47 assault rifle and Glock handgun were confiscated in February 2016 after Montana, a welder at Ingalls Shipbuilding, showed up at the Pascagoula shipyard and complained to security that people were stealing on Ingalls property. A Naval Criminal Investigative Service agent was called to the shipyard, which builds warships for the U.S. Navy, and believing that Montana might be experiencing mental issues, took Montana's employee badge and made him leave, telling him not to return until given permission.

A motion filed last week by Montana's attorney and obtained by the Sun Herald said that Montana left, but came back stating that he was being followed and had been forced to use drugs. Security officers took him to the hospital and secured his truck, where the loaded weapons were later found.

The weapons were turned over to the Pascagoula Police Department, the court document said.

A judge committed Montana to a South Mississippi State Hospital, where he stayed for 10 days. He was released without medication, the motion said.

Montana went to Pascagoula police in late November or early December 2017, telling Capt. Shannon Broom that doctors had cleared him of mental issues and requesting his guns back. Broom, who wrote in a memo that Montana seemed normal, told him that he would release the weapons by order of a municipal court judge.

A city judge, relying on Broom’s observations of Montana, issued a court order that gave Montana the weapons back.

Montana showed up at the police station in Pascagoula on Feb. 6, nearly two years after the incident at the shipyard, and complained to Broom that Ingalls security officers were following him.

"Further, among other statements, defendant stated the 'reason he was at the shipyard in 2016 was because he was trying to tell the director of security that the man (who) signed his welding certificate had a daughter that was killed, and he knew people in the shipyard killed her, and they knew he knew,'" the motion stated.

Broom, who was alarmed at the “extreme difference” in Montana’s demeanor since seeing him just four months before, called Ingalls security and the Bureau of Alcohol, Tobacco, Firearms and Explosives.

Federal agents arrested Montana on the weapons charges Feb. 23 at his grandparents' house, where he lives, the Sun Herald reported.

Montana's attorney, Melvin Cooper, argued in the motion that Broom knew or should have known that Montana was prohibited from possessing his guns before he returned them to him in December. He also pointed out that the judge's order releasing the weapons ordered them to be given to a man named Marty Jeffrey Slade, not Montana.

The order was later modified, with Slade's name marked through, to show that the guns were returned to Montana, the motion said. Cooper also noted that the police release form shows the guns were given back to Montana two days before the court order was issued.

Cooper argued that the charges against Montana amount to entrapment. He asked the court to dismiss the indictment against his client.

Montana remains in the Harrison County Jail, where he is being held without bail on a hold for U.S. Marshals, jail records show. His trial is set for the May court calendar, the Sun Herald reported.