Obama condemns discrimination on Lesbians, Gay, Bisexual, and Transgenders
A gunman killed 49 people on Sunday morning at a gay nightclub in the city.
Mr Obama challenged the Republican-controlled Congress to pass gun control legislation.
But Republican Senator John McCain said the president was “directly responsible” because he had failed to tackle the Islamic State group.
Gunman Omar Mateen claimed allegiance to the militant group as he carried out the massacre.
The senator said: “When he pulled everybody out of Iraq, al-Qaeda went to Syria, became Isis [Islamic State], and Isis is what it is today thanks to Barack Obama’s failures, utter failures, by pulling everybody out of Iraq.”
He later clarified that he did not mean the president was personally responsible.
On Thursday, hundreds of people gathered outside the Amway Center in Orlando as the president and Vice-President Joe Biden consoled relatives inside.
“I held and hugged grieving relatives and they asked: Why does it keep happening?” Mr Obama said, adding: “They don’t care about the politics.”
The two men laid wreaths at a makeshift memorial and met the owners of the Pulse nightclub where the shooting took place.
The gunman, the president said, had violated a sanctuary for the LGBT (lesbian, gay, bisexual and transgender) community and now people should reflect on how to end violence and discrimination against them, in the US and overseas.
According to data collected by the New York Times, LGBT people are more likely to be targets of hate crime than any other minority group.
Mr Obama also urged Congress to pass gun control legislation.
“We will not be able to stop every tragedy. We can’t wipe away hatred and evil from every heart in this world, but we can stop some tragedies. We can save some lives. We can reduce the impact of a terrorist attack if we’re smart,” he said.
“And if we don’t act, we will keep seeing more massacres like this. Because we will be choosing to allow them to happen.”
The attack – using a semi-automatic rifle – has sparked renewed calls for tighter gun laws and one member of Congress spoke for 15 hours on Wednesday in an attempt to force the Senate to act.
Mateen, who was shot dead at the club by police, was on a terror watch list while the FBI investigated him over inflammatory remarks. But they concluded he was no terror threat.
Opponents of changes to the law want guarantees that law-abiding Americans will not have their rights infringed upon.
Gun control is a very divisive issue in the US, where the right to bear arms is enshrined in the constitution.
It is unclear why Mateen, a 29-year-old born in New York, carried out the killings.
It has emerged that before or during the attack, he raged on Facebook about the “filthy ways of the West”.
There are also claims by friends and family that he had a hatred for gay people, although he had frequented this gay nightclub many times and used gay dating apps.