BEIRUT, Lebanon — Lebanon’s prime minister, Saad Hariri, was summoned at 8:30 a.m. to the Saudi royal offices — unseemly early, by the kingdom’s standards — on the second day of a visit that was already far from what he had expected.

Mr. Hariri, long an ally of the Saudis, dressed that morning in jeans and a T-shirt, thinking he was going camping in the desert with the crown prince, Mohammed bin Salman.

But instead he was stripped of his cellphones, separated from all but one of his usual cluster of bodyguards, and shoved and insulted by Saudi security officers. Then came the ultimate indignity: He was handed a prewritten resignation speech and forced to read it on Saudi television.

This, it seemed, was the real reason he had been beckoned to the Saudi capital, Riyadh, a day earlier: to resign under pressure and publicly blame Iran, as if he were an employee and not a sovereign leader. Before going on TV, he was not even allowed to go to the house he owns there; he had to ask guards to bring him a suit.