Updated

Republican Sen. John McCain said Thursday he “misspoke” after initially calling President Obama "directly responsible" for the mass shooting in Orlando, because of the rise of the Islamic State on his watch.

McCain, who lost to Obama in the 2008 presidential election, made the comment Thursday while Obama was in Orlando visiting with the families of those killed in Sunday's attack and some of the survivors.

"Barack Obama is directly responsible for it, because when he pulled everybody out of Iraq, Al Qaeda went to Syria, became ISIS, and ISIS is what it is today thanks to Barack Obama's failures, utter failures, by pulling everybody out of Iraq," a visibly angry McCain told reporters in the Capitol as the Senate debated a spending bill.

"So the responsibility for it lies with President Barack Obama and his failed policies," McCain said.

After McCain took heat on those comments from Democrats, he clarified on Twitter that he was referring to Obama’s national security decisions and not the president himself.

He later issued a written statement saying: “I misspoke. I did not mean to imply that the President was personally responsible. I was referring to President Obama’s national security decisions, not the President himself. As I have said, President Obama’s decision to completely withdraw U.S. troops from Iraq in 2011 led to the rise of ISIL.”

The gunman, Omar Mateen, killed 49 people and injured more than 50 in the attack at a gay nightclub. The 29-year-old Muslim born in New York made calls during the attack saying he was a supporter of the Islamic State.

In the aftermath of the shooting, presumptive Republican presidential nominee Donald Trump has accused Obama of putting U.S. enemies ahead of Americans. Trump also was accused of suggesting that Obama himself might sympathize with radical elements.

Democrats criticized Trump and some Republicans tried to distance themselves from his remarks.

Before McCain clarified, Adam Jentleson, a spokesman for Senate Minority Leader Harry Reid, D-Nev., said McCain's "unhinged comments are just the latest proof that Senate Republicans are puppets of Donald Trump."

The Associated Press contributed to this report.