Authorities were investigating the attack on the Florida dance hall as an act of terrorism. The suspect attack was identified as Omar Mateen of Port St. Lucie, Florida.
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.
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.
First names of the victims in Orlando nightclub shooting released
"There's blood everywhere," Orlando Mayor Buddy Dyer said.
All of the dead were killed with the assault rifle, according to Rep. Alan Grayson. Law enforcement sources said Mateen used 30-round capacity magazines with his AR-15 rifle. The source stated some of the magazines were taped together, allowing him to reload quickly by popping the expended magazine, flipping it over and inserting the fresh magazine.
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 exchanged gunfire with a police officer working at the club, which had more than 300 people inside. The gunman then went back inside and took hostages, Police Chief John Mina said.
Around 5 a.m., authorities sent in a SWAT team to rescue the hostages.
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, Mir Seddique, 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."
The law enforcement official said Mateen was known to the FBI before the nightclub attack and had been looked at by agents within the last few years.
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.
In a statement, Mateen's employer G4S said he had worked for the security company since September of 2007. G4S said it was fully cooperating with law enforcement officials, including the FBI, during their investigation.
G4S said Mateen went through two background checks, once in 2007 and once in 2013. The company said it learned Mateen was questioned by the FBI, but was told the inquiries were closed. G4S said it was not aware of any alleged connections between Mateen and terrorist activities.
President Barack Obama called the shooting an "act of terror" and an "act of hate" targeting a place of "solidarity and empowerment" for gays and lesbians. He urged Americans to decide whether this is the kind of "country we want to be."
In addition to the guns, the shooter also had some sort of "suspicious device," the police chief said.
Authorities said they had secured a van owned by the suspect outside the club. Meanwhile, a SWAT truck and a bomb-disposal unit were on the scene of an address associated with Mateen in a residential neighborhood of Fort Pierce, Florida, about 118 miles southeast of Orlando.
Relatives and friends, many in tears, gathered outside the hospital to learn the fate of loved ones.
Smith did not know the conditions of her wounded friends. She came out of the hospital and burst into tears.
Pulse shooting: In hail of gunfire in which suspect was killed, OPD officer was hit. Kevlar helmet saved his life. pic.twitter.com/MAb0jGi7r4— Orlando Police (@OrlandoPolice) June 12, 2016
Christine Leinonen drove to Orlando at 4 a.m. after learning of the shooting from a friend of her 32-year-old son, Christopher Leinonen, who was at Pulse and is missing.
She had not heard from her son and feared the worst.
"These are nonsensical killings of our children," she said, sobbing. "They're killing our babies!"
She said her son's friend Brandon Wolf survived by hiding in a bathroom and running out as the bullets flew.
A woman who was outside the club early Sunday was trying to contact her 30-year-old son, Eddie, who texted her when the shooting happened and asked her to call police. He told her he ran into a bathroom with other club patrons to hide. He then texted her: "He's coming."
"The next text said: 'He has us, and he's in here with us,'" Mina Justice said. "That was the last conversation."
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."
A bartender said she initially thought the gunshots were music. But after a second shot, there was a pause, followed by more shots. That's when Tiffany Johnson realized something was wrong.
Johnson said people dropped to the ground and started running out of the club. She ran to a fast-food restaurant across the street and met one of her customers who let her get in his car. They drove away.
Club-goer Rob Rick said the shooting started just as "everybody was drinking their last sip."
He estimated more than 100 people were still inside when he heard shots, got on the ground and crawled toward a DJ booth. A bouncer knocked down a partition between the club area and an area where only workers are allowed. People were then able to escape through the back of the club.
Christopher Hansen said he was in the VIP lounge when he heard gunshots. He continued to hear shooting even after he emerged and saw the wounded being tended across the street.
"I was thinking, 'Are you kidding me?' So I just dropped down. I just said, 'Please, please, please, I want to make it out,'" he said. "And when I did, I saw people shot. I saw blood. You hope and pray you don't get shot."
The owner of Pulse, Barbara Poma, released the following statement: "Like everyone in the country, I am devastated about the horrific events that have taken place today. Pulse, and the men and women who work there, have been my family for nearly 15 years. From the beginning, Pulse has served as a place of love and acceptance for the LGBTQ community. I want to express my profound sadness and condolences to all who have lost loved ones. Please know that my grief and heart are with you."
The attack follows the fatal shooting late Friday of 22-year-old singer Christina Grimmie, a YouTube sensation and former contestant on "The Voice." She was killed after an Orlando concert by a 27-year-old man who later killed himself.