Authorities were investigating the attack on the Florida dance club as an act of terrorism. The gunman's father recalled that his son recently got angry when he saw two men kissing in Miami and said that might be related to the assault.
The shooter called 911 shortly before the attack and referenced ISIS, FBI agent Ronald Hopper said.
At least 53 people were hospitalized, most in critical condition, officials said. A surgeon at Orlando Regional Medical Center said the death toll was likely to climb.
"There's blood everywhere," Orlando Mayor Buddy Dyer said.
All of the dead were killed with the assault rifle, according to Rep. Alan Grayson, a Florida Democrat.
Witnesses described a chaotic scene when the gunfire began shortly before the club known as Pulse was to close.
"Some guy walked in and started shooting everybody. He had an automatic rifle, so nobody stood a chance," said Jackie Smith, who had two friends next to her get shot. "I just tried to get out of there."
The suspect was identified as Omar Mateen, a 29-year-old American citizen from Port St. Lucie, Florida, who had worked as a security guard. Mateen's ex-wife said his family was from Afghanistan but that her ex-husband was born in New York. His family later moved to Florida.
The shooter in 2013 made inflammatory comments to co-workers, and Mateen was interviewed twice, Hopper said. He called those interviews inconclusive.
In 2014, Hopper said, officials found that Mateen had ties to an American suicide bomber. He described the contact as minimal, saying it did not constitute a threat at the time.
Mateen purchased at least two firearms legally within the last week or so, according to Trevor Velinor of the Bureau of Alcohol, Tobacco and Firearms.
The suspect exchanged gunfire with 14 police officers at the club, which had more than 300 people inside.
At one point, he took hostages, Police Chief John Mina said. Around 5 a.m., authorities sent in a SWAT team to rescue the hostages.
Pulse posted on its own Facebook page around 2 a.m.: "Everyone get out of Pulse and keep running." Just before 6 a.m., the club posted an update: "As soon as we have any information, we will update everyone. Please keep everyone in your prayers as we work through this tragic event. Thank you for your thoughts and love."
In addition to the assault rifle, the shooter also had some sort of "suspicious device," the police chief said.
In the immediate aftermath of the attack, police departments across the country stepped up patrols in neighbourhoods frequented by the LGBT community.
Authorities were looking into whether the attack was an act of domestic or international terrorism, and if the shooter acted alone, according to Danny Banks, an agent with the Florida Department of Law Enforcement.
"This is an incident, as I see it, that we certainly classify as domestic terror incident," Orange County Sheriff Jerry Demings said.
The previous deadliest mass shooting in the U.S. was the 2007 attack at Virginia Tech, where a student killed 32 people before killing himself.
Mateen's father, Seddique Mir Mateen, told NBC News about his son seeing the men kissing a couple of months ago.
"We are saying we are apologizing for the whole incident," Seddique said. "We are in shock like the whole country."
A federal law enforcement official with knowledge of the investigation said Mateen was known to the FBI before the nightclub attack and had been looked at by agents within the last few years. The official was not authorized to discuss the investigation publicly and spoke on condition of anonymity.
The matter for which he came under investigation was "open and closed pretty quickly," the official said.
When asked if the gunman had a connection to radical Islamic terrorism, Hopper said authorities had "suggestions that individual has leanings towards that."
Mateen's father said the attack had nothing to do with religion, he said.