ORLANDO, FLA.—It had been an evening of drinking, dancing and drag shows. After hours of revelry, the party-goers crowding the gay nightclub known as the Pulse took their last sips before the place closed.

That’s when authorities say Omar Mateen emerged, carrying an AR-15 and spraying the helpless crowd with bullets. Witnesses said he fired relentlessly — 20 rounds, 40, then 50 and more. In such tight quarters, the bullets could hardly miss. He shot at police. He took hostages.

When the gunfire finally stopped, 50 people were dead and dozens critically wounded in the deadliest mass shooting in modern U.S. history. Mateen, who authorities said had pledged allegiance to Daesh in a 911 call shortly before the attack, died in a gun battle with SWAT team members.

Authorities immediately began investigating whether the assault was an act of terrorism and probing the background of Mateen, a 29-year-old American citizen from Fort Pierce, Florida, who had worked as a security guard. 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.

Thirty-nine of the dead were killed at the club, and 11 people died at hospitals, Mayor Buddy Dyer said.

Jon Alamo had been dancing at the Pulse for hours when he wandered into the club’s main room just in time to see the gunman. “You ever seen how Marine guys hold big weapons, shooting from left to right? That’s how he was shooting at people,” he said.

Live Blog: City of Orlando responds to mass shooting

“My first thought was, oh my God, I’m going to die,” Alamo said. “I was praying to God that I would live to see another day.”

Pulse patron Eddie Justice texted his mother, Mina: “Mommy I love you. In club they shooting.” About 30 minutes later, hiding in a bathroom, he texted her: “He’s coming. I’m gonna die.” As Sunday wore on, she awaited word on his fate.

At least 53 people were hospitalized, most in critical condition, and a surgeon at Orlando Regional Medical Center said the death toll was likely to climb.

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 family was from Afghanistan, and he was born in New York. His family later moved to Florida, authorities said.

A law enforcement official said the gunman made a 911 call from the club in which he professed allegiance to the leader of Daesh, Abu Bakr al-Baghdadi. The official was familiar with the investigation, but was not authorized to discuss the matter publicly and spoke on condition of anonymity.

The extremist group did not officially claim responsibility for the attack, but the Daesh-run Aamaq news agency cited an unnamed source as saying the attack was carried out by a Daesh fighter.

Even if the attacker supported Daesh, also known as the Islamic State group or ISIS, it was unclear whether the group planned or knew of the attack beforehand.

Mateen was not unknown to law enforcement: In 2013, he made inflammatory comments to co-workers and was interviewed twice, according to FBI agent Ronald Hopper, who called the interviews inconclusive. In 2014, Hopper said, officials found that Mateen had ties to an American suicide bomber, but the agent described the contact as minimal, saying it did not constitute a threat at the time.

Asked if the gunman had a connection to radical Islamic terrorism, Hopper said authorities had “suggestions that individual has leanings towards that.”

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.

In a separate incident, an Indiana man armed with three assault rifles and chemicals used to make explosives was arrested Sunday in Southern California and told police he wanted to do harm to a gay pride parade.

The Orlando shooting started about 2 a.m., with more than 300 people inside the Pulse.

“He had an automatic rifle, so nobody stood a chance,” said Jackie Smith, who saw two friends next to her get shot. “I just tried to get out of there.”

At 2:09 a.m., Pulse posted on its Facebook page: “Everyone get out of Pulse and keep running.”

Mateen exchanged gunfire with 14 police officers at the club, and took hostages at one point. In addition to the assault rifle, the shooter also had a handgun and some sort of “suspicious device,” the police chief said. About 5 a.m., authorities sent in a SWAT team to rescue the remaining club-goers, Police Chief John Mina said.

At first, officers mistakenly thought the gunman had strapped explosives to the dead after a bomb robot sent back images of a battery part next to a body, Orlando Mayor Buddy Dyer said. That prevented paramedics from going in until authorities determined the battery was something that fell out of an exit sign or a smoke detector, he said.

The robot was sent in after SWAT team members put explosive charges on a wall and an armoured vehicle knocked it down in an effort to rescue hostages.

Just before 6 a.m., the Pulse posted an update on its Facebook: “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.”

Authorities were looking into whether 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.

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.”

Mateen was a security guard with a company called G4S. In a 2012 newsletter, the firm identified him as working in West Palm Beach. In a statement sent Sunday to the Palm Beach Post, the company confirmed that he had been an employee since September 2007. State records show that Mateen had held a firearms license since at least 2011.

U.S. 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.”

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 Fort Pierce, about 120 miles southeast of Orlando.

Across the country, police departments stepped up patrols in neighbourhoods frequented by the LGBT community.

Loading... Loading... Loading... Loading... Loading... Loading...

American Muslim leaders on Sunday were also condemning the attack on a gay nightclub.

Nihad Awad, the executive director of the Council on American-Islamic Relations, called the killings a hate crime and said the group has no tolerance for extremism of any kind.

A law enforcement official has said the gunman, Omar Mateen, called 911 from the nightclub and expressed allegiance to an Islamic State leader.

Awad says members of the LGBT community have stood with Muslims in the past and today they stand that community.

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 neighbourhood 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.

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 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.

World response to Orlando mass shooting

“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 attack follows the fatal shooting late Friday of 22-year-old singer Christina Grimmie, who was killed after her concert in Orlando by a 27-year-old Florida man who later killed himself. Grimmie was a YouTube sensation and former contestant on “The Voice.”

More on thestar.com:

Florida nightclub shooting suspect was known to FBI, official says

Florida nightclub attack latest in U.S. mass deadliest shootings

Toronto vigil to be held Sunday for victims of Orlando nightclub massacre

Survivors of Orlando mass shooting recall struggle to stay alive

Trudeau calls Florida shooting a ‘domestic terror attack’ against LGBT community

Ideology usually just a rationale for mentally ill attackers, says expert

Photos: Aftermath of the Florida massacre, deadliest mass shooting in U.S. history