Aaron Alexis lived for a time in a bungalow in the woods near a Buddhist temple in Fort Worth, where he occasionally joined Thai immigrants in meditation. Aaron Alexis died Monday in a gun battle with police at the Washington Navy Yard after he allegedly killed at least 12 people.

Along the way, the man named as the shooter in Monday’s mass killing at Building 197 was discharged from the Navy Reserve, arrested after firing a bullet through his upstairs neighbor’s floor and then asked to leave his Fort Worth apartment.

One Navy official, speaking on the condition of anonymity, said that Alexis was discharged in January 2011 for “a pattern of misconduct” and that the 2010 gun incident in Texas played a role in his departure.

But Alexis, 34, had no trouble landing a civilian job. He moved from Fort Worth to Washington about a month ago, friends said, and was hired as an hourly tech employee for The Experts, a Hewlett-Packard subcontractor that is updating computer systems at Navy and Marine Corps installations worldwide. He was scheduled to begin work at the Washington Navy Yard this month.

Those who knew Alexis in recent years describe him as a “sweet and intelligent guy” (a regular customer at the Thai restaurant where he had been a waiter) and “a good boy” (his landlord), but also as “very aggressive,” someone who seemed as though he might one day kill himself (a lay worker at the Buddhist temple where Alexis worshiped).

That angry streak flared often enough to create an arrest record in three states.

In 2004, Alexis was arrested in Seattle after he fired three shots from a Glock pistol into the tires of a Honda Accord that two construction workers had parked in a driveway adjacent to Alexis’s house. Alexis’s father told detectives then that his son “had experienced anger management problems that the family believed was associated with PTSD,” or post-traumatic stress disorder, according to the police report. The father said Alexis had been “an active participant in rescue attempts of Sept. 11, 2001.”

Alexis’s explanation for his behavior that day: The construction workers had “mocked” and “disrespected” him and then he had “a black-out fueled by anger.”

He was arrested but not charged, Seattle police said. The paperwork apparently was lost.

“That report never got to the Seattle city attorney’s office,” said Kimberly Mills, a spokeswoman for the city attorney. “Consequently, we never filed charges.”

In 2008, Alexis was arrested on a disorderly conduct charge in DeKalb County, Ga. He spent two nights in jail, police said, but they had no other details.

More recently, Alexis struck those who crossed his path as a man of sharp contrasts. He was learning the Thai language, visited Thailand for a month, was studying for an online degree in aeronautical engineering, and enjoyed conversing with diners, according to friends, customers and fellow worshipers. But some said he had an aggressive streak that made them keep their distance and avoid personal questions.

“He’s a 13-year-old stuck in a 34-year-old body,” said Oui Suthamtewakul, owner of the Happy Bowl Thai restaurant in White Settlement, Tex., and a friend who lived with Alexis for most of the past three years. “He needs attention.”

Alexis often worked as an unpaid waiter for Suthamtewakul and his wife, Kristi, but lived with them rent-free. The couple described Alexis as a helpful, chatty guy who liked to watch cooking shows on TV.

“He always hit on girls,” Suthamtewakul said, adding that he had to scold his friend for being too forward with female customers.

Suthamtewakul said Alexis “had a gun at all times” and fired a bullet through the wall of his room in the summer of 2012. “You’re gonna kill me,” the restaurateur told his friend. Alexis apologized and said it was an accident.

Alexis drank alcohol frequently and in large quantities, Suthamtewakul said: “He can start drinking at 9:30 in the morning. He drinks often and for fun, but it was never a problem.” Asked what he will remember about his friend, Suthamtewakul said, “Him with a Heineken.”

Alexis grew up in Brooklyn with his parents, Cathleen and Anthony Alexis, said his aunt Helen Weekes. “We haven’t seen him for years,” she said.

He spent nearly four years in the Navy as a full-time reservist from May 2007 until January 2011, according to the Navy. A Navy official, speaking on the condition of anonymity, said that Alexis received a general discharge for “misconduct” and that the 2010 firearms incident in Texas played a role in his departure.

Alexis achieved his final rank — aviation electrician’s mate 3rd class — in December 2009.

He spent the bulk of his service time — 2008 to 2011 — assigned to the Fleet Logistics Support Squadron 46 at Naval Air Station Fort Worth, records show. He received the Global War on Terrorism Service Medal and the National Defense Service Medal, awards of minor distinction.

Despite the circumstances surrounding his discharge, Alexis apparently was issued a government contractor access card that would have allowed him into the Navy Yard and other military installations, said Thomas Hoshko, chief executive of The Experts. His security clearance was updated in July.

“There had to be a thorough investigation,” Hoshko said. “There is nothing that came up in all the searches.”

Alexis had finished a contract in Japan for the company at the end of 2012, Hoshko said.

“Nobody could have done anything to prevent this except Aaron Alexis,” he said. “Maybe he snapped. I don’t know.”

In Fort Worth, Alexis lived for a time in a gated townhouse community called Orion at Oak Hill. In September 2010, police were called to Apartment 2023 after Alexis’s upstairs neighbor complained that a bullet had been fired through her apartment. Police determined that Alexis had fired a round that went up through her floor and into her ceiling.

The woman told police that Alexis had complained several times that she was too loud. She said he had confronted her a few days earlier in the complex’s parking lot “about making too much noise,” according to a police report.

The woman said that “she is terrified of Aaron and feels that this was done intentionally,” the police report said.

Police tried three times to contact Alexis by knocking on his apartment door, but he didn’t respond. Only after they called in firefighters to force entry did he emerge. He told police that he had been cleaning his gun while cooking and that it accidentally discharged because his hands were greasy, according to the police report.

“He told me that he began to take the gun apart when his hands slipped and pulled the trigger, discharging a round into the ceiling,” the officer wrote. Alexis was arrested for improperly discharging a firearm, but the county district attorney’s office said Monday that there was not enough evidence to pursue the case. Alexis’s mug shot from that arrest shows a clean-shaven man with soft eyes and an impassive expression.

A couple of weeks later, the apartment complex began eviction proceedings against Alexis, according to county records.

Soon after, Somsak Srisan, a Thai immigrant in Fort Worth, met Alexis at the Wat Busayadhammavanaram Meditation Center, where Alexis had occasionally practiced meditation starting in the summer of 2010. Alexis said he needed a place to stay, and Somsak offered him a two-bedroom white bungalow a short walk away — if he promised not to smoke or drink. Alexis rented the place for $600 a month and never missed a payment, said Somsak, 57.

“He’s a good boy,” said Somsak, who spoke halting English. “Everybody would say, ‘He’s a good boy.’ ”

Alexis occasionally meditated at the temple and helped there when needed, said Somsak, who was impressed that his tenant studied the Thai language and visited Thailand.

On Monday, as word spread about the shootings, the temple filled with members eager to share recollections of Alexis. “They don’t believe it that he could kill 12 people like that,” Somsak said. “I think probably somebody tried to put him down. I don’t know. Did somebody try to discriminate against him?”

Somsak asked Alexis only once why he had left his job at the naval base. It was a brief conversation.

“I asked him, ‘Why you quit the job with the government?’ ” Somsak said. “He said, ‘Somebody doesn’t like me.’ ”

Somsak left it there, he said, because “I don’t want to go too deep with him.”

Alexis visited the center about twice a week and was known as a quiet, if tightly wound, participant, a temple staff member said.

“He would help people if they came in carrying heavy things,” said J. Sirun, an assistant to the monks. “From the outside, he was a quiet person. But on the inside, I think he was very aggressive. He did not like to be close with anybody, like a soldier who has been at war.”

Sirun said he avoided Alexis, who preferred to keep to himself. But Alexis was no loner; he had many Thai friends and spoke Thai “very well,” Sirun said. “He understood about 75 percent of the language.”

Customers saw him studying Thai at a table there during his off hours. Alexis stopped showing up at the Buddhist center early in 2011, he said. “I didn’t think he could be this violent,” he said. “I would not have been surprised to hear he had committed suicide. But I didn’t think he could commit murder.”

Relatives contacted by reporters were stunned to hear that Alexis was suspected in the shootings. “I’d be shocked if it was him, but I don’t know,” said Weekes, his aunt, her voice trailing off.

Even as he worked for the defense contractor, Alexis was pursuing a bachelor’s degree in aeronautics as an online student at Embry-Riddle Aeronautical University. The university, in Daytona Beach, Fla., said he enrolled in July 2012 via the school’s Fort Worth campus. He remained a student in good standing, said Melanie Hanns, director of university communications.

“He was enrolled for this semester,” she said.

FBI Assistant Director Valerie Parlave asked the public to call 1-800-CALL-FBI with any details about Alexis.

Marjorie Censer, David A. Fahrenthold, Jennifer Jenkins, Carol D. Leonnig, Annys Shin, Julie Tate and Craig Whitlock in Washington and special correspondent Leslie Minora in Fort Worth contributed to this report.