Federal prosecutors alleged Tuesday that a frequent Fox News commentator charged with lying about a 27-year career with the CIA to win government contracting jobs referenced his purported clandestine work often when he saw a benefit to himself.

In one instance, prosecutors alleged, he told police officers who were trying to stop him from assaulting a cabdriver something to the effect of: “I’m CIA. You can’t do anything to me.”

“He’s always using this supposed CIA affiliation as a trump card,” Assistant U.S. Attorney Paul Nathanson said in court. “Frankly, it often works.”

A federal magistrate judge ultimately ordered Wayne S. Simmons detained pending further legal proceedings, saying that the 62-year-old Annapolis man might pose a danger to the community. Noting Simmons’s criminal record and apparent affinity for guns, the judge, Ivan D. Davis, said he could not be certain that Simmons would follow any conditions that were set for his release.

Wayne Simmons is shown in this screengrab from an appearance on Fox News. (Fox News)

Prosecutors asserted in court that Simmons was convicted previously of assault, gambling and being a felon in possession of a firearm and said that he had 11 charges for drinking and driving. Not all of those charges could be immediately corroborated in court records available online. Prosecutors said the alleged assault on the cabdriver occurred in Annapolis in 2007; more details could not immediately be learned.

Simmons was arrested last week and charged with making false statements, major fraud against the United States and wire fraud. By prosecutors’ account, Simmons lied on government documents about a career with the CIA to help him win interim security clearances and real jobs with two different government contractors, including BAE Systems. He was also charged with persuading someone to give him $125,000 for a real estate investment, then using the money on personal expenses.

On his Web site, Simmons claimed he was recruited by the CIA to work as part of an “Outside Paramilitary Special Operations Group” and that he “spearheaded Deep Cover Intel Ops against some of the world’s most dangerous Drug Cartels and arms smugglers from Central and South America and the Middle East.” A frequent, unpaid commentator on Fox News, he mingled easily with other military and media types, and some who knew him said he talked knowledgeably enough that they did not doubt his credentials.

Fox News host Neil Cavuto, who had Simmons on his show, has since apologized for what he termed “a very big slip-up” if the allegations against Simmons are true. A Fox News spokeswoman has not responded to questions on what process the network used to check Simmons’s claims of his expertise.

Nathanson said in court Tuesday that Simmons never had any association with the CIA and cast him instead as a man with a litany of legal and financial problems. He alleged that Simmons’s home in Annapolis was either in foreclosure or in imminent risk of foreclosure — Simmons has not made a mortgage payment since 2010 — and that his car was repossessed last month. He said that although Simmons claimed his fictional spy thriller, “The Natanz Directive,” would be made into a movie in 2016, that was only partly true.

Someone paid $1,250 for the option to make a movie from the book about three years ago, then re-upped recently for the same price, Nathanson said. He said Simmons’s only source of income was periodic financial support from his sister.

Urging Davis to order Simmons held pending further court proceedings, Nathanson also alleged that Simmons had a “long-standing affinity and association with firearms” and might present a danger to those around him.

Nathanson noted that even though Simmons was banned from owning guns because of his previous convictions, investigators found two when they arrested him, and he even worked in 2010 as a consultant and firearms distributor for Adcor Defense. (An Adcor representative did not immediately return messages seeking comment.)

Simmons also claimed to be a business partner of an arms dealer who has been charged criminally in Arizona, Nathanson said. He said Simmons was someone “whose world has essentially come crashing down on him.”

“We believe Mr. Simmons is in a desperate situation right now,” Nathanson said.

Whitney Minter, Simmons’s attorney, countered that Simmons had been the target of the federal investigation for two years, and in that time, he had neither tried to flee nor acted inappropriately. She asked Davis to allow Simmons to live in his home under his daughter’s supervision. The judge rejected that request.

Simmons’s relatives declined to comment after the hearing.

Simmons is scheduled to appear in court Friday for a formal arraignment, court records show.