Media playback is unsupported on your device Media caption The BBC's Gordon Corera examines what we know about the attacker

Omar Mateen was a US citizen who had been known to the FBI since 2013.

He opened fire inside a gay nightclub in Orlando, Florida in the early hours of Sunday, killing 49 people in the deadliest shooting in modern US history.

FBI officials say the 29-year-old, who was killed by police, appeared to "have leanings towards" radical Islamist ideology, although it was not clear whether the attack was a case of domestic or international terrorism.

Mateen made emergency 911 calls shortly beforehand in which he reportedly stated his allegiance to Islamic State.

The group later said that an IS "fighter" had carried out the attack, but did not specify whether it was directly involved or simply taking credit for inspiring it.

Image caption Omar Mateen, pictured in an undated photograph, worked as a security guard

What we know

Eyewitness accounts

Meanwhile Mateen's father told NBC News the attack "had nothing to do with religion".

Seddique Mateen said his son became "very angry" after seeing two men kissing in downtown Miami recently.

He said the family had not been aware that Mateen might have been planning an attack. "We are in shock like the whole country."

But there are also reports Mateen used gay dating apps and was a regular at the club where he carried out the massacre.

Ty Smith told the Orlando Sentinel he had seen Mateen at least 12 times at the Pulse, saying he would sometimes drink heavily, becoming "loud and belligerent".

Image copyright Reuters Image caption Friends and family members embrace outside the Orlando police headquarters

As questions emerged about the gunman's history, FBI Special Agent Ron Hopper told reporters that Mateen had been interviewed by FBI officers twice in 2013 following inflammatory comments to colleagues asserting ties to IS.

The investigation ended after officers were unable to substantiate the claims. However, Mateen was questioned again in 2014 about a potential connection to Moner Mohammad Abu-Salha, the American known to have carried out a suicide bombing in the Syria conflict.

The FBI investigation found no "substantial relationship" between Mateen and Abu-Salha and the case was closed, said Special Agent Hopper.

Despite being on the FBI's radar, Manteen was not on an official terrorism watch list and was able to legally hold a state firearms licence, according to Florida records.

It has emerged that Mateen had worked as an armed security officer for the firm G4S since 2007.

Police say he attacked the Pulse nightclub wielding an assault-type rifle and a handgun.

Image copyright Reuters Image caption Omar Mateen posted a series of selfies on social media

Image copyright Reuters Image caption In some of the photos online, Mateen is pictured wearing unofficial NYPD T-shirts

Mateen was born in New York to Afghan parents but had moved to Fort Pierce, a city about two hours' drive south of Orlando.

His ex-wife, Sitora Yusufiy, has said that he was violent and mentally unstable and had beaten her repeatedly.

The pair married in Fort Pierce in 2009 after meeting online, but her parents intervened and removed her from their home just months later after learning of his abuse.

"He was not a stable person," she told the Washington Post. "He beat me. He would just come home and start beating me up because the laundry wasn't finished or something like that."

She told the newspaper that Mateen had not been very religious when she was with him and he had regularly exercised at the gym. She said he had owned a small-calibre handgun and worked as a guard at a nearby facility for juvenile delinquents.

Speaking to reporters later on Sunday, Ms Yusufiy said Mateen was bi-polar and although some commentators were trying to link his actions to IS or religion, the real cause was mental illness.

The couple divorced in 2011.

Boston bombing cited

Police believe Mateen rented a car and drove to Orlando to carry out the attack on the nightclub, according to media reports.

In his alleged call to 911, he is said to have referred to the 2013 Boston Marathon bombers, Tamerlan and Dzhokhar Tsarnaev.

In a series of social media photos, Mateen is seen wearing T-shirts emblazoned with the New York Police Department name and emblem.

However, the NYPD said Mateen had no association with the department and the shirts were unofficial merchandise that could be bought at any shop.

The gunman had filed a petition for a name change in 2006 from Omar Mir Seddique to Omar Mir Seddique Mateen, according to US media.

It has emerged that his father, Seddique Mateen, has a television show on a California-based channel that expresses anti-Pakistani government views and sympathy for the Afghan Taliban.