Police killed the shooter at the Pulse nightclub, who was identified as Omar S. Mateen, a 29-year-old Florida resident and US citizen. A top US congressman said Mateen may have pledged allegiance to the Islamic State militant group.
"We know enough to say this was an act of terror, an act of hate," Obama said in a speech from the White House. "And as Americans, we are united in grief, in outrage and in resolve to defend our people."
US officials have reached no definitive judgment on the killer's precise motives, Obama added. "We must spare no effort to determine what, if any, inspiration or association this killer may have had with terrorist groups," he said.
Fifty-three people were wounded in the rampage. It was the deadliest single US mass shooting incident, eclipsing the 2007 massacre of 32 people at Virginia Tech university.
Pulse was crowded with some 350 revelers at a Latin music night when the attack happened.
"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.

Video footage showed police officers and civilians carrying 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.
"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.
Dyer said 39 people were killed inside the club, two outside, and nine others died after being rushed to hospital.
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.

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

IS claims responsibility for shooting
Islamic State's Amaq news agency said on Sunday that the Islamist militant group was responsible for the shooting that killed at least 50 people in a massacre at a gay nightclub in Orlando, Florida.
"The armed attack that targeted a gay night club in the city of Orlando in the American state of Florida which left over 100 people dead or injured was carried out by an Islamic State fighter," Amaq said.
