WASHINGTON — President Donald Trump lashed out at the three Republicans and 48 Democrats he said had let down the American people by defeating a slimmed-down GOP Senate bill to replace Obamacare early on Friday.

3 Republicans and 48 Democrats let the American people down. As I said from the beginning, let ObamaCare implode, then deal. Watch! — Donald J. Trump (@realDonaldTrump) July 28, 2017

Hours before the vote, the president had exhorted Republican lawmakers to pass the bill, which was brought up for a vote after a string of efforts to repeal and replace the health care law that was enacted under former President Barack Obama.

"Go Republican Senators, Go! Get there after waiting for 7 years. Give America great healthcare!" Trump wrote on Thursday night.

Later, Senate Republicans failed to pass the bill on a vote of 49 to 51. Three Republicans — Susan Collins, John McCain and Lisa Murkowski — and all Democrats opposed it.

Trump made the repeal of Obamacare a key promise of his campaign for president, saying that it would be replaced by something better and less expensive.

McCain, whose vote against the "skinny repeal" of Obamacare came as a last-minute surprise to at least some of his fellow Republicans, has called for bipartisan cooperation to pass legislation delivering affordable health care.

McCain's comments early Friday echoed remarks he made on the floor of the Senate earlier in the week when he made a dramatic return to the Senate after brain surgery.

"I’ve stated time and time again that one of the major failures of Obamacare was that it was rammed through Congress by Democrats on a strict party-line basis without a single Republican vote," he said in a statement.

"We must now return to the correct way of legislating and send the bill back to committee, hold hearings, receive input from both sides of aisle, heed the recommendations of nation’s governors, and produce a bill that finally delivers affordable health care for the American people," he added.

Republican lawmakers said they remained committed to replacing Obamacare.

"The democratic process is a long process," said Sen. Ted Cruz, R-Texas, after the vote. "I believe this Congress will come back and will with time honor our promises."

Sen. Lamar Alexander, R-Tenn., who serves as chairman of the Senate's committee on health, labor and education, said he would work to solve what he called an urgent health care problem in his state.

"The Senate's failure to do this leaves an urgent problem that I am committed to addressing: Tennessee's state insurance commissioner says our individual insurance market is very near collapse," he said in a statement.

For their part, Democratic senators said they were not celebrating the bill’s defeat.

"We are relieved. Not for ourselves, but for the American people," said Sen. Chuck Schumer, D-N.Y., the minority leader.

Fighting off tears, he praised McCain for his vote against the GOP bill and called for Democrats and Republicans to work together to craft a bill that would improve Obamacare.

Schumer said that McCain had "asked us to go back to regular order, to bring back the Senate that some of us who have been here a while remember."

"Maybe this can be a moment where we can start doing that," he said. "Both sides will have to give. The blame hardly falls on one side or the other. But if we can take this moment, a solemn moment, and start working this body the way it had always worked until the last decade or so…we will do a better job for our country."

Leigh Ann Caldwell reported from Washington, and Rachel Elbaum from London.