WASHINGTON — The Navy has ordered a review of security at U.S. military bases after police say a contractor with a record of gun-related arrests and a checkered military career killed 12 people at the Washington Navy Yard.

Shootings attributed to Aaron Alexis, 34, prompted fresh scrutiny of how the military reviews security clearances granted to those who work for private contractors. Alexis entered the base with a valid identification, which he secured despite being discharged from the Navy Reserves following a pattern of misconduct during his nearly four-year career.

“It really is hard to believe that someone with a record as checkered as this man could conceivably get clearance, could get credentials, to be able to get on the base,” Washington Mayor Vincent Gray said during an interview Tuesday with CNN. “This is one of the most secure facilities in the nation. So how this could happen is beyond belief.”

Navy Secretary Ray Mabus ordered a review of base security, to be submitted to his office by Oct. 1. It came as Rep. Mike Turner, R-Ohio, said a Pentagon inspector general’s report revealed flaws in how the Navy and Marine Corps approve access to military bases by government contractors.

Turner wrote in a letter to the Pentagon Inspector General’s office Monday about concern that the audit disclosed “serious security flaws” that potentially lets criminals get widespread access to military installations.

The audit found that “potentially numerous felons may have been able to gain unrestricted access to several military installations across the country due to the insufficient background checks, increasing the risk to our military personnel and civilian employees,” Turner said in the letter.

Alexis was granted a secret-level clearance in March 2008 after an investigation by the federal Office of Personnel Management, according to a defense official who asked not to be named discussing personnel matters. After leaving the Navy in January 2011, Alexis retained the clearance, which was good for 10 years, and wasn’t subject to a reinvestigation, the official said.

About 3.5 million Americans held secret or confidential clearances as of October 2012, including about 582,524 who worked for contractors, according to data from the Office of the Director of National Intelligence.

Scrutiny of Navy security came as details of Monday’s shooting, the deadliest since the December massacre at a Connecticut elementary school, focused on the Alexis’s background before securing his job at The Experts Inc., a Fort Lauderdale, Fla.-based company that works on computer networking equipment. The company said in a statement that it is cooperating with the FBI.

Alexis had been treated since August by the Department of Veterans Affairs for mental health issues, including paranoia and a sleep disorder, the Associated Press reported today, citing law enforcement officials it didn’t identify. The Navy hadn’t declared him mentally unfit, which would have ended his security clearance, the news agency said.

Authorities have released the names of all 12 shooting victims. Eight others were injured in the incident, including three who were shot, and all are expected to recover, Gray said.

The shooting, carried out with a high-powered weapon, unleashed a day of chaos in the nation’s capital after it was reported about 8:15 a.m. Washington time at the headquarters of the U.S. Naval Sea Systems Command, where about 3,000 people work.

Alexis had legal access to the Navy yard as result of his work there as a contractor and used a “valid pass” to gain entry, according to Valerie Parlave, assistant FBI director in charge of the Washington field office.

A portrait emerged of a man drawn to Buddhist meditation who was rattled by the Sept. 11 terrorist attacks and had encounters with police in Texas and Washington State after gun-related incidents. The agency asked the public for any additional information on the suspect.

Alexis, who was born in New York City, enlisted in the Navy in 2007 and served in recruit training and logistics in Illinois and Texas, according to the Navy. He was last assigned to a logistics support squadron in Fort Worth, Texas, according to the Navy.

He was removed from the Navy Reserve in 2011 because of a pattern of misconduct during his service years that included an arrest in Texas, according to a Navy official who asked not to be identified discussing personnel matters.

Fort Worth police arrested Alexis on Sept. 4, 2010, after an upstairs neighbor reported that a bullet came through her floor from the apartment below, where Alexis lived.

The neighbor said Alexis had called the police several times complaining she was being loud, and that several days beforehand, Alexis had confronted her in the parking lot for making too much noise.

Alexis told officers he was cleaning a gun when it went off, according to police records. The woman told police that “she is terrified of Aaron and feels that this was done intentionally,” according to the report.

Alexis was arrested, though Tarrant County authorities declined to file a case against him for reckless discharge of a firearm after determining that he was cleaning his gun.

In 2004, Alexis was arrested by Seattle police on suspicion of shooting out the tires of a construction worker’s vehicle, according to the Seattle Police Department. Alexis told police that he had been mocked and disrespected by construction workers. The police didn’t say how it was resolved, and online court records had no information on the case.

Alexis worked for the Experts firm, a subcontractor of Hewlett-Packard Co., on a contract to upgrade equipment on the Navy Marine Corps Intranet network, according to a statement by Michael Thacker, a Hewlett-Packard spokesman. He held a valid military ID card, called a common-access card, permitting entry into most facilities, the Washington Post reported, citing Experts Chief Executive Officer Thomas Hoshko.

“We are actively cooperating with the FBI and other authorities in relation to the investigation on the suspect,” according to a statement from Experts.