Police killed the shooter, who was identified as Omar S. Mateen, a 29-year-old Florida resident and U.S. citizen. A top U.S. congressman said Mateen may have pledged allegiance to the Islamic State militant group.
U.S. officials cautioned, however, that they had no immediate evidence of any direct connection with Islamic State or any other foreign extremist group, nor had they uncovered any contacts between the gunman and any such group.
Fifty-three people were wounded in the rampage. It was the deadliest single U.S. mass shooting incident, eclipsing the 2007 massacre of 32 people at Virginia Tech university.
"Today we're dealing with something that we never imagined and is unimaginable," Orlando Mayor Buddy Dyer said, more than doubling an earlier estimate that about 20 bodies had been found.
A police officer working as a security guard inside the Pulse nightclub exchanged fire with the suspect at about 2 a.m. (0600 GMT), authorities said. Pulse was crowded with some 350 revelers at a Latin music night.
"Everyone get out of pulse and keep running," the club's management wrote on Facebook as the incident unfolded.
A hostage situation developed, and three hours later SWAT team officers used armored cars to storm the club before shooting dead the gunman. It was unclear when the victims were killed.
Dozens of terrified patrons, some of whom had been hiding in restrooms, were rescued. One officer was injured when he was hit in his helmet while exchanging fire with the gunman, police said.
A man was arrested in California with assault weapons and possible explosives on Sunday and told authorities he was in the Los Angeles area for the gay pride festival, the Los Angeles Times reported.
Representative Adam Schiff, the top Democrat on a congressional intelligence committee, noted that the Orlando shooting took place during Ramadan, and that Islamic State leaders who control territory in Syria and Iraq have urged attacks during this time.
According to local law enforcement, the shooter had declared his allegiance to Islamic State, Schiff said in a statement, all of which "indicates an ISIS-inspired act of terrorism."
Likely Republican presidential nominee Donald Trump said he was "right on radical Islamic terrorism" and called for toughness and vigilance. Democratic candidate Hillary Clinton tweeted a brief statement after the attacks, but did not speculate on the motives of the gunman.
FOX News Channel reported that Mateen was known to the FBI as recently as 2013, citing an unnamed source.
If confirmed as an act of terrorism, it would be the deadliest such attack on U.S. soil since Sept. 11, 2001, when al Qaeda-trained hijackers crashed jetliners into New York's World Trade Center, the Pentagon and a field in Pennsylvania, killing some 3,000 people.
A pair of ethnic Chechen brothers killed three people and injured more than 260 with a pair of homemade pressure-cooker bombs at the Boston Marathon in April 2013.
Asked if the FBI suspected the gunman might have had inclinations toward militant Islamism, including a possible sympathy for Islamic State, Ronald Hopper, an assistant FBI agent in charge, told reporters: "We do have suggestions that the individual may have leanings toward that particular ideology. But right now we can't say definitively."
U.S. Senator Marco Rubio of Florida, who sits on the Senate intelligence and foreign relations committees, told CNN he understood that the gunman had worked for a security company and so would have undergone some background checks.
President Barack Obama ordered the federal government to provide any assistance needed to Florida police investigating the shooting, the White House said. He was due to speak later Sunday.
The attacker was carrying an AR-15 style assault rifle and a handgun, Orange County Sheriff Jerry Demings said. He was also carrying an unidentified "device", said Orlando Police Chief John Mina.
Video footage showed police officers and civilians carrying some people away from the club and bending over others on the ground. Dozens of police cruisers, ambulances and other emergency vehicles could be seen in the area.
Dyer said 39 people were killed inside the club, two outside, and nine others died after being rushed to hospital.
The choice of target was especially heart-wrenching for members of the U.S. lesbian, gay, bisexual and transgender community, said LGBT advocacy group Equality Florida.
"Gay clubs hold a significant place in LGBTQ history. They were often the only safe gathering place and this horrific act strikes directly at our sense of safety," the group said in a statement. "We will await the details in tears of sadness and anger."
Orlando has a population of more than 270,000 and is the home of the Disney World amusement park and many other tourist attractions that drew 62 million visitors in 2014.
It was the second deadly shooting at an Orlando night spot in as many nights. Late Friday, a man thought to be a deranged fan fatally shot singer Christina Grimmie, a former contestant on "The Voice", as she was signing autographs after a concert.