Former resrvist Aaron Alexis worked as a subcontractor to the computer company after being discharged from navy in 2011

The man responsible for Monday's deadly rampage at the Washington navy yard was a subcontractor and former reservist who was arrested at least twice in the past for gun-related offences.

Aaron Alexis, 34, was discharged from the navy in 2011 after an incident in which an upstairs neighbour complained that he had shot into the floor of her apartment.

But Alexis restored his connections with the navy when a professional services company subcontracted by Hewlett-Packard employed him on a navy IT project. His ID badge gained him access to the navy yard base on Monday, the FBI said.

According to the US navy, Alexis, whose home was listed as New York City, enrolled in the reserves in 2007. He was a navy aviation electrician's mate third class from 1 February 2008 until he was discharged on 31 January 2011. He is listed as having received the national defense service medal and the global war on terrorism service medal.

In 2010, while he was based at Fort Worth in Texas, he was arrested after discharging a firearm. In 2004, police in Seattle questioned him after what they described as an "anger-fuelled shooting" involving the car of a construction worker.

Seattle police said on Monday that during their inquiries into the 2004 incident, Alexis's father reported that he suffered from "anger management problems associated with PTSD, and that Alexis had been an active participant in rescue attempts on September 11, 2001".

The statement went on: "Following his arrest, Alexis told detectives he perceived he had been 'mocked' by construction workers the morning of the incident, and said they had 'disrespected him'. Alexis also claimed he had an anger-fueled 'blackout' and could not remember firing his gun at the victims' vehicle until an hour after the incident.

"Alexis also told police he was present during 'the tragic events of September 11, 2001' and described 'how those events had disturbed him'," the police statement said.

According to a Texas police report, Alexis was arrested in September 2010 on suspicion of discharging a firearm in a municipality, but not formally charged.

The police report from the time states that an officer was dispatched to Orion at Oak Hill, a large, gated apartment complex in west Fort Worth, after a woman called the police and said that she believed someone had fired a shot into her apartment.

According to the report, the woman was "visibly shaken up". She said that Alexis was her downstairs neighbour, and that he had "called the police several times on her for being loud". The woman reported that Alexis had confronted her in the parking lot about making too much noise.

The report adds that the woman told the officer that she was "terrified" of Alexis and believed that the shot had been fired intentionally. The report states that the officer knocked on Alexis's door but did not receive a response. He only emerged after the officer called the fire department to get them to forcibly enter the property.

Alexis claimed to have discharged the gun accidentally, the report says. "He said that he was trying to clean his gun while cooking and that his hands were slippery," the witer of the report says. "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."

In both instances, Alexis was not charged. Court records reviewed by the Associated Press how he was released on the condition he not have contact with any of the workers. In Texas, it was determinded that Alexis had discharged his gun by accident.

After leaving the reserves, Alexis worked as a waiter and delivery driver at the Happy Bowl Thai restaurant in White Settlement, a suburb of Fort Worth, according to Afton Bradley, a former co-worker, quoted by the Associated Press.

Having travelled to Thailand, Alexis learned some Thai and could speak to Thai customers in their native language. "He was a very nice person," Bradley said in a phone interview. "It kind of blows my mind away. I wouldn't think anything bad at all."

A former acquaintance, Oui Suthametewakul, said Alexis lived with him and his wife from August 2012 to May 2013 in Fort Worth, but that they had to part ways because he was not paying his bills. Alexis was a "nice guy," Suthametewakul said, though he sometimes carried a gun and would frequently complain about being the victim of discrimination.

Suthametewakul said Alexis had converted to Buddhism and prayed at a local Buddhist temple. Ty Thairintr, a congregant at Wat Budsaya, a temple in Fort Worth, told the AP: "We are all shocked. We are nonviolent. Aaron was a very good practitioner of Buddhism. He could chant better than even some of the Thai congregants."

Thairintr said that Alexis told him and others at the temple that he had taken a job as a contractor and he indicated to them he was going to go to Virginia. He last saw Alexis five weeks ago. "He was a very devoted Buddhist. There was no tell-tale sign of this behaviour," Thairintr said.

Hewlett-Packard confirmed that Alexis worked for a subcontractor. It said in a statement: "Aaron Alexis was an employee of a company called 'The Experts,' a subcontractor to an HP Enterprise Services contract to refresh equipment used on the navy marine corps intranet (NMCI) network. HP is cooperating fully with law enforcement as requested."

It said the company was "deeply saddened" by the incident. "Our thoughts and sympathies are with all those who have been affected," the company said.

On its website, The Experts, whose headquarters are in Alexandria, Virginia, describes itself as providing "innovative and mission-critical IT, engineering and litigation professional services for federal, state and local governments and departments".

It said in a statement: "The Experts would like to express our deepest condolences and sympathies regarding the incident that occurred at the DC naval yards. We are actively cooperating with the FBI and other authorities in relation to the investigation on the suspect. Any additional information we have will be shared accordingly."

On Monday night, officers from the New York Police Department cordoned off a section of the tree-lined street in the Bedford-Stuyvesant neighbourhood of Brooklyn, where family of Alexis lives in a brownstone apartment.

A huddle of NYPD officers stood in the road outside the three-storey building, watched by a small crowd of reporters and TV crews. Earlier in the day, Anthony Little, the brother-in-law of the uspect, emerged from the house and told NBC4 the family were "distraught". He said: "It's a shocking experience. Nobody expected this. No-one saw it coming. No-one knew anything. So all of this is just shocking."

Little, who is married to Alexis's sister, said he had never met him.

Embry-Riddle Aeronautical University, which offers online courses in aviation and aerospace, confirmed that Alexis was enrolled as an online student via its Fort Worth campus, started classes in July 2012 and had been pursuing a bachelor's of science in aeronautics. "We are cooperating fully with investigating officials," the university said.

The Associated Press contributed to this report