Authorities say the guns were found in the former officer’s vehicle. (U.S. Attorney’s Office for the District)

A former Tennessee police officer who was arrested outside the White House on Sunday had a cache of weapons in his car and told authorities he came for help removing a chip he thought had been implanted in his head, according to court documents.

Several of the firearms were loaded and some were described as assault-style weapons, including an AR-15 and an AK-47, according to authorities.

A spokesman for the Memphis Police Department said the suspect, Timothy J. Bates, 37, of Collierville, Tenn., had been an officer there for 13 years before leaving in 2013. Court records show he was allowed to retire early because of medical issues.

A D.C. Superior Court judge on Monday ordered Bates detained until a preliminary hearing on Thursday. An arrest affidavit says Bates was committed for mental health issues in February.

Bates is charged with several firearms offenses. His relatives could not be reached. His attorney, Lisbeth Sapirstein, declined to comment.

Authorities said uniformed U.S. Secret Service officers stopped Bates about 7:15 a.m. on Sunday near 17th Street and Pennsylvania Avenue NW after it appeared he was about to urinate in public.

Bates told the officer that he drove through the night from Tennessee and “came to the White House in order to speak with Adm. Mike Rogers and Gen. Jim Mattis for advice on missing paychecks and how to get the dog chip out of my head,” according to the affidavit. Navy Adm. Michael S. Rogers is director of the National Security Agency; Mattis is the secretary of defense.

The arrest affidavit says Bates told the officers that a chip had been implanted while he was on the police force in Memphis and that it was part of a $28.7 million project called “MK Ultra.”

Police said they searched Bates’s silver 2009 Nissan 370Z and found guns, ammunition and other weapons.

The guns, according to the arrest affidavit, include a Bushmaster M-4 semiautomatic rifle along with 90 rounds of ammunition; an AR-47 rifle; a Norinco AK-47 rifle; a .45-caliber Glock pistol; an Intratec Tec-9 pistol with a silencer; a Rossi .357-caliber revolver and a Smith & Wesson .45-caliber handgun. Police said they also recovered a Vulcan V10 .45-caliber firearm, which they said qualifies as a fully operational machine gun.

Authorities said the firearms are illegal in the District. Court papers did not describe any plan to use the weapons.

The affidavit says the Bushmaster and AK-47 rifles were in the car and “within arms reach of the driver.” One was out of its case and on the passenger seat; the other was in a case between the passenger and driver’s seats.

Authorities also said they found a set of brass knuckles, a blackjack and three knives.

Magda Jean-Louis and Keith L. Alexander contributed to this report.