But in the marble hallway of Beirut's presidential palace Wednesday, Hariri said that he had agreed to delay his resignation to hold a "dialogue" that would lead Lebanon out of crisis.
The announcement appeared to roll back a bold push by Saudi Arabia in recent weeks aimed at countering Iranian influence across the region.
"There is nothing more precious than our country," Hariri told supporters in Beirut. "I am staying with you, and I will keep going with you to be the first line of defense of Lebanon, its stability and its Arab nature."
Hariri had initially blamed his resignation on Iran, accusing it of sowing "sedition, devastation and destruction in any place it settles in." But Lebanese politicians and Western officials saw the catalyst as Saudi Arabia's desire to contain Hezbollah, an Iranian proxy around the region and a powerful political force in Lebanon.
Hariri's three-week absence marked the most bizarre twist yet in the life of a politician who has outlived an assassinated father and spent years in self-imposed exile after an earlier spell as prime minister was ended by a Hezbollah walkout from government.
The Nov. 4 resignation was followed by two weeks spent in Riyadh, much of it out of sight, which sparked frenzied speculation over whether Hariri was being held there against his will.
In an emotional interview last week, the 48-year-old politician looked exhausted.
Hariri made no mention Wednesday of the speculation over his constrained movements within Saudi Arabia. But Paula Yacoubian, the journalist who interviewed him, said that she had not dealt with any Saudi officials at his residence, and described the prime minister as largely relaxed during her time there, although he had clearly lost weight.
As a Lebanese-Saudi national, Hariri's personal business interests have long been buoyed and buffeted by Saudi politics, with the family's Saudi Oger firm falling heavily into debt as the kingdom's oil fortunes have fallen and Saudi Crown Prince Mohamed bin Salman spearheads economic changes.
Hariri's speech appeared to signal that Saudi Arabia's regional ambitions could now end his political career, too.
Within hours of the speech, Saudi authorities began a far-reaching campaign of arrests within Saudi Arabia, many of its targets appearing to be Mohamed's political rivals. It also tightened an already devastating humanitarian blockade on Yemeni ports and airspace, increasing pressure on Iran-backed rebels that Saudi Arabia is fighting there, and alarming aid officials who warned that 7 million people could be pushed into famine as a result.
The prime minister's return to Beirut appeared to have been helped by French diplomatic efforts. Hariri spent the weekend in Paris, and stopped for talks in Egypt and Cyprus before touching down on Lebanese soil late Tuesday, in time for the country's Independence Day.
The Trump administration, while not advocating Hariri's side trip to Paris, had made clear to the Saudis, and to Hariri himself, that "getting back to Beirut was essential," a U.S. official said. "We accepted Paris as an alternative, but we just wanted to make sure it was temporary. We were not comfortable with a life in exile."
French President Emmanuel Macron, who spoke directly to the crown prince about Hariri's return, "was one factor," said the official, who spoke on the condition of anonymity to comment on diplomatic efforts.
The White House sees Saudi Arabia as key to two major foreign policy goals: bringing Iran to heel; and forging a settlement between Israel and the Palestinians. But the administration is less than pleased about recent actions by Riyadh that it considers distractions from those objectives. In addition to the Hariri episode, it has pushed Saudi Arabia to settle its ongoing dispute with Qatar and to ease its blockade of Yemen to allow passage of humanitarian aid.
Hariri's announcement Wednesday that he would be staying in his post appeared to signal that the Saudi gambit had failed. Hours later, Riyadh announced that the blockade on Yemen's ports and airspace would be eased — although aid agencies warned that the humanitarian effects would remain disastrous.
In a sign of just how confusing his three-week absence has been, even those close to Hariri said that they were surprised by his announcement.
"Yesterday we had the impression that he was going to resign. . . . It is clear that a compromise was reached," Yacoubian said.
By midmorning Wednesday, crowds of supporters in downtown Beirut erupted in celebration, raising banners and blasting songs from the back of pickup trucks. "We were very worried for him the whole time he was gone," said Rana Alamadin, 45. "But now? It's a beautiful day."
Karen DeYoung and Brian Murphy in Washington contributed to this report.