He threatened. He tweeted. He lost.

President Donald Trump might be forgiven for thinking he could bully U.S. senators to vote for a measure even GOP lawmakers said they did not actually want to become law. They needed a win, the president needed a win and the bare-knuckled tactics had worked before, helping him to win the presidential election.

Instead, Trump was hit with a major loss in the wee hours of Friday morning, when three tough-as-nails Republican senators joined a united Democratic caucus to defeat a partial repeal of the Affordable Care Act. Republicans promised that the so-called "skinny repeal," which would have eliminated the health insurance mandate of Obamacare, was just a vehicle to force a negotiating session with the House on a more comprehensive package.

That wasn't enough for GOP Sens. Susan Collins of Maine, Lisa Murkowski of Alaska, and most dramatically, John McCain of Arizona, who didn't let an aggressive brain tumor or last-ditch, on-the-floor lobbying by Vice President Mike Pence stop him from giving a quietly defiant thumbs-down to the proposal.

"There is a reason why the famous political scientist Richard Neustadt said years ago that presidential power is the power to persuade. Not the power to command - to persuade," says Whit Ayres, a veteran GOP consultant and pollster. Trump, Ayres says, tried to bully lawmakers and suffered a backlash. And it was predictable to anyone who can do the math, he notes.

"Many of these senators are more popular in their states than Donald Trump is. Most of the senators who won re-election in 2016 ran ahead of Donald Trump in their states," Ayres adds. "That means that those senators tend to think the president owes them, rather than that they owe the president."

Trump crowed about being a master dealmaker, but "he's just proven that he's an amateur. He certainly doesn't understand how Congress works," says University of Akron political science professor David B. Cohen, who is co-authoring a book on the White House chief of staff position.

The loss magnifies a nascent Capitol Hill trend, Cohen says, where Republicans are starting to push back more against their president. The Senate Thursday followed the House in passing a measure imposing new sanctions on Russia to punish the nation for alleged meddling in the U.S. election. Should Trump veto the bill, he is virtually certain to be overridden, as both chambers approved the measure by near-unanimous margins.

Meanwhile, lawmakers in both parties are pushing back hard against Trump's announcement that transgender people could no longer serve in the military "in any capacity." The military chiefs have said they will not yet change current policy, as Trump's pronouncement was made in a tweet and not a presidential directive.

GOP senators are also sending strong signals to Trump that he should not get rid of Attorney General Jeff Sessions, who has angered Trump by recusing himself in the Russia inquiry and has been publicly humiliated by the president. Sen. Lindsey Graham, R-S.C., said he will introduce legislation to protect the special prosecutor position so Trump could not fire Robert Mueller, who is investigating the Russia matter.

The health care vote was a dramatic loss for Trump, who had made not-so-veiled threats with wavering GOP senators. He'd held a White House event in late June to talk strategy on the Obamacare repeal effort, with Murkowski seated to one side of him and Collins, the other, delivering the visual suggestion they were on his side. Turns out, they weren't.

At another event in July, Trump was seated next to Nevada GOP Sen. Dean Heller, the most imperiled of Republican Senate incumbents and someone who had worried about the impact of repeal on his state's Medicaid recipients. "He wants to remain a senator, doesn't he?" Trump said, drawing an uncomfortable chuckle from Heller. In the end, Heller voted for the repeal measure.

Meanwhile, Trump operatives are talking to potential primary challengers to both Heller and Arizona Sen. Jeff Flake. A pro-Trump group, America First policies, launched a radio and TV ad campaign against Heller when the lawmaker was wavering on the health care bill.

Murkowski, meanwhile, got a call from Interior Secretary Ryan Zinke, who told her that her initial "no" vote to start formal debate on a bill that was then still being written had disappointed the president. The administration's relationship with Alaska was at stake, the Alaska Dispatch News reported Zinke as saying.

Trump himself took Murkowski to task personally in a tweet, typing: "Senator @lisamurkowski of the Great State of Alaska really let the Republicans, and our country, down yesterday. Too bad."

Taking on Murkowski and Collins was a curious strategy from the start. Murkowski, after all, won her second Senate election as a write-in, having lost the GOP nomination that year to a challenger from the right (and enduring resentment from party establishment figures who expected her to bow out after losing that primary so as not to divide the conservative vote). She also won last year by a hair more than Trump's margin of victory in Alaska, despite having multiple general election opponents.

Collins remains one of the Senate's most popular lawmakers with her constituents, ranking sixth with a 67 percent approval rating, according to Morning Consult. She was cheered in her home state when she voiced her opposition to an Obamacare replacement plan that threatened Medicaid.

McCain, it seems, was a vote Trump took for granted, perhaps failing to understand the maverick Republican's history and thinking. When McCain interrupted his brain cancer treatment to return to D.C., Trump cheered him on Twitter. "So great that John McCain is coming back to vote. Brave - American hero! Thank you John," Trump tweeted about the man candidate Trump said was not a true American hero because he was captured in the Vietnam War.