ORLANDO, Fla. (Reuters) - President Barack Obama on Thursday met survivors of a massacre at an Orlando gay nightclub and relatives of the 49 people killed and said the United States must act to control gun violence and fight what he called homegrown terrorism.

“I held and hugged grieving family members and parents, and they asked, ‘Why does this keep happening?’,” Obama told reporters, before urging Congress to pass measures to make it harder to legally acquire high-powered weapons like the semi-automatic rifle used in the attack on Sunday.

“I’m pleased to hear that the Senate will hold votes on preventing individuals with possible terrorist ties from buying guns,” he said.

Obama and Vice President Joe Biden arrived in Orlando, Florida, four days after a U.S.-born gunman claiming allegiance to various Islamist militant groups carried out the deadliest mass shooting in modern U.S. history.

During the shooting rampage the gunman, Omar Mateen, exchanged text messages with his wife, it was reported on Thursday, as well as posting on Facebook and placing a phone call to a television station. Police killed Mateen, 29, a U.S. citizen born in New York to Afghan immigrants.

Obama, who has visited mass shooting victims’ families in towns from San Bernardino, California, to Newtown, Connecticut, since he has been president, laid flowers at a memorial for the victims of the attack on the Pulse nightclub.

Islamic State claimed responsibility for the attack but U.S. officials have said they do not believe Mateen was assisted from abroad. CIA Director John Brennan told a Senate Intelligence Committee hearing on Thursday that the agency had “not been able to uncover any direct link” between Mateen and militants abroad.

A married couple also claiming allegiance to Islamic State shot dead 14 people in San Bernardino, California, in December.

ORLANDO MOURNS

Wakes were held on Thursday for at least four victims - Kimberly Morris, Anthony Luis Laureano Disla, Eric Ivan Ortiz-Rivera and Roy Fernandez, as Orlando braced for what was expected to be two weeks of somber events.

More than 300 people, including Florida Governor Rick Scott, came to the viewing for Ortiz-Rivera, who was born in Dorado, Puerto Rico. He was 36 when he was killed during a night of dancing to celebrate a friend’s new house - his husband had stayed home that night in the couple’s apartment.

“He was in a Snapchat video that’s out there, dancing away, so we know he had some fun before the madness,” said his cousin, Orlando Gonzalez.

Twenty-three of the 53 wounded remained hospitalized, six in critical condition, according to the Orlando Regional Medical Center.

Slideshow ( 25 images )

One of Mateen’s Facebook messages during the attack, apparently referring to air strikes against Islamic State by the United States and its allies, said: “You kill innocent women and children by doing us air strikes ... now taste the Islamic State vengeance,” according to U.S. Senate Homeland Security Committee Chairman Ron Johnson, who asked Facebook to turn over material from Mateen’s accounts.

CNN reported, citing a law enforcement official it did not identify, that Mateen had also exchanged text messages with his wife, Noor Salman, during the three hours he was holed up in a bathroom inside the nightclub. Salman is under investigation to find out whether she knew about Mateen’s plans ahead of time.

Florida news website TCPalm reported that Mateen, who worked as a security guard, was frequently suspended while he was in junior high and high school, and was passed to the next grade despite poor academic performance. It cited records from St. Lucie County schools.

Slideshow ( 25 images )

CONGRESS UNDER PRESSURE

The attack sparked a new debate over how the United States responds to Islamist militant violence at home and abroad, with Republican Senator John McCain telling reporters on Thursday he viewed Obama as “directly responsible” for the Orlando attack because of his failure to prevent the rise of Islamic State.

Shortly afterward, McCain said on his official Twitter feed that he was referring to Obama’s national security decisions, “not to the President himself.”

Mateen carried out the slaughter with an assault weapon and handgun that had been legally purchased although he had twice been investigated by the FBI for possible connections with militant Islamist groups.

Obama reiterated his frustration over the failure of Congress to pass any gun control measures in more than two decades. The massacre put pressure on Congress to act.

After a marathon of speeches by Democrats on Wednesday and into the early hours of Thursday, a Democratic senator said Republicans had agreed to hold votes on measures to expand background checks and prevent people on U.S. terrorism watch lists from buying guns.

No formal deal between the parties for votes was announced, and it was unclear when and how the Senate would proceed with the votes, which would be amendments to an appropriations bill funding the Commerce and Justice departments. Even if votes are scheduled, it is unclear whether any of the bills could gain enough support to pass the Senate.

Senator John Cornyn of Texas, the No. 2 Republican in the Senate, said the chamber would most likely vote on four gun control measures on Monday.

Republicans, who currently hold a 54-person majority in the 100-seat Senate, have blocked a number of Democratic-backed gun control measures over the years, saying they infringed on Americans’ constitutional right to bear arms.

Presumptive Republican presidential nominee Donald Trump also joined the gun debate, announcing on Wednesday he would meet the National Rifle Association to talk about barring people who are on terrorism watch lists from buying guns.