Media playback is unsupported on your device Media caption Speaking in Orlando, Mr Obama said that the gun control debate needed to change

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.

Senator McCain 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."

Image copyright Reuters Image caption Vice-President Biden and President Obama visited the memorial in Orlando

Image copyright AP Image caption Orlando Mayor Buddy Dyer and Mr Obama embraced when the president landed

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.

Image copyright Getty Images Image caption A wake took place on Thursday for one of the victims, Javier Jorge-Reyes

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

At the scene - Rajini Vaidyanathan, BBC News, Orlando

The piles of flowers, cards and letters outside Orlando's Dr Phillips Centre for the Performing Arts are getting larger. In the baking heat, people continue to arrive at this memorial to the victims.

Some kneel on the grass, bowing their heads in contemplation. Others embrace one another, before they leave their tribute. "Hate will never win," reads one of the many signs. It's a sentiment felt by many in the LGBT community here, who believe breaking down barriers of prejudice can be one lasting legacy from this horrific attack.

Across the city, rainbow flags have started to hang from shop fronts and outside bars and restaurants. As President Obama arrives here to meet the families, there's hope he can bring comfort at this anguished time. But there's also hope that this horror can bring harmony.

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.

Media playback is unsupported on your device Media caption BBC Pop Up helped Florida residents create a video message to the global gay community

Media playback is unsupported on your device Media caption Orlando shooting witness: Nowhere feels safe

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.