Trump International Hotel in Washington, D.C. (Paul J. Richards/AFP/Getty Images)

A Pennsylvania man arrested at Trump International Hotel in downtown Washington after a military-style rifle was found in his vehicle was ordered released from detention Thursday despite having said that he came to the District with guns and ammunition to meet with President Trump.

Court documents say Bryan Moles, 43, arrived in the District with an AR-15 rifle, a handgun and more than 90 rounds of ammunition and had survival gear to stay until he met Trump to bring down “big pharmacy and big business medicine.”

Moles was arrested in his hotel room early Wednesday when police said he made statements referring to deadly bombings in the 1990s at the federal building in Oklahoma City and at the Olympics in Atlanta.

Magistrate Judge Joseph E. Beshouri of D.C. Superior Court ordered Moles to stay overnight at an undisclosed hotel, under guard and confined to his room pending a federal court hearing scheduled for Friday.

Moles also is barred from going near the White House and the Trump hotel and must surrender the Bushmaster AR-15 rifle, a handgun found in his vehicle and other weapons that were at his home, located near Lake Erie.

The scene outside D.C. Superior Court June after the release Thursday of Bryan Moles, 43, of Edinboro Pennsylvania, with his attorney, Eugene Ohm of the D.C. Public Defender Service. (Keith Alexander/The Washington Post)

The overnight release followed a protracted Superior Court hearing in which the prosecutor dropped a request that Moles be held on two criminal counts: unlawful possession of a firearm, a federal offense, and unlawful transport of a firearm, a District offense.

It was the federal offense that seemed to sow some confusion.

Beshouri appeared critical of the prosecutor’s failure to inform him that a federal charge was being pursued, and he took a break to research the law on detention.

At the hearing, Beshouri also expressed concern with Moles’s keen interest in Oklahoma City bomber Timothy Mc­Veigh.

When court resumed, the defense attorney and prosecutor told the judge that they had reached an agreement on Moles’s release.

Outside the courthouse, Moles declined to comment on the case, but he said of his family, “I love them and I’ll talk to them soon.”

Moles, 43, a licensed physician and former Navy corpsman, drove to the District from his home town 100 miles north of Pittsburgh in a black 2017 BMW loaded with ammunition, batteries, multiple cellphones and survival supplies, a court document states.

Prosecutors said he invoked the memories of domestic bombers Mc­Veigh in 1995 and Eric Rudolph in Centennial Olympic Park in Atlanta in 1996.

On Wednesday, while authorities alluded to threats made by Moles, they said they did not have enough evidence to charge him with making threats. Still, D.C. Police Chief Peter Newsham said that police and a tipster had brought a “potential tragic situation to a peaceful end.”

Court documents released Thursday show that even without a specific threat, there appeared cause for concern. The documents portray a man who apparently supported Trump and told police that he suffers from post-traumatic stress disorder but refused his medication; owned more than 20 guns at his home near Edinboro, Pa.; and had experience with explosives and pipe bombs.

According to the criminal complaint, Moles told detectives that before his road trip, he had withdrawn $10,000 “to live the life he always wanted before it was too late.”

He said that he left $4.19 in his checking account because the digits were significant to him and that he had once written a term paper on Mc­Veigh, who killed 168 people in the April 19, 1995, bombing of the Alfred P. Murrah Federal Building.

In court Thursday, prosecutor Michael Friedman argued that Moles was a danger.

“He said he wanted to meet with President Trump and would not leave 1600 Pennsylvania Avenue until he saw him,” Friedman said, adding that Moles called himself a “refugee” and that he came to Washington to “bring down big medicine business and big pharmacy.” Friedman said the alleged crimes were “committed under concerning circumstances.”

But Moles’s attorney, Eugene Ohm of the D.C. Public Defender Service, argued that his client committed no crime other than not knowing the District’s strict gun laws.

“Dr. Moles is a father of two, a 14-year veteran of the Navy and eight-year reservist who has multiple marksmanship ribbon awards,” Ohm said, arguing that his client was neither a danger to the community nor a flight risk and should be released.

He said visitors come to the District not knowing the gun laws “about three or four times a week.”

Ohm argued that Moles “believed he was acting lawfully” when he told a valet at the Trump hotel he had the weapons in his car.

Police were already searching for Moles by the time he arrived at the Trump hotel and parked his car, telling the valet to secure it because he had weapons inside, according to the criminal complaint.

Police said detectives went to the hotel about 1:50 a.m. and saw a rifle case in the car in plain view and opened the door using a keyless entry system that the valet had been given. Inside, police found the rifle, two 30-round high capacity magazines and a loaded Glock 23 inside the unlocked glove box.

Police said they had received a tip from an acquaintance who had listened to a voice-mail recording from Moles and relayed information to Pennsylvania State Police.

D.C. police and Secret Service agents went to Moles’s room and said he opened the door and agreed to speak to them, the court document shows. He told investigators, according to the complaint, that he brought the AR-15 to the District to have a friend customize it for his son’s use back home.

The complaint says he told police that he was a recovering alcoholic who has been sober since 2013 and that he suffered from PTSD and medicated with marijuana instead of prescription drugs because the medications made him suicidal.

Moles enlisted in the U.S. Navy in 1992 and served until August 1996 as a hospital corpsman at Camp Lejeune, N.C., Navy records show. Moles served in the reserves until 1996 as part of a surgical battalion. He also had apparently worked at a hospital until 2013.

Moles repeatedly talked about Mc­Veigh and Rudolph, an antiabortion and anti-gay activist who committed a string of bombings, including one at Centennial Olympic Park during the 1996 Summer Olympics in Atlanta, which killed one person and injured more than 100.

The complaint says Moles quipped on his voice-mail message that he had stockpiled his car with so much survival gear that it “looked like Timothy Mc­Veigh or Eric Rudolph was going on a camping trip.”