Discrimination against LGBT people must be tackled at home and abroad, President Obama has said after meeting relatives of Orlando attack victims.
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.”