BEIRUT, Lebanon — A month after he declared under Saudi Arabian pressure that he was quitting his post, Lebanon’s prime minister officially rescinded his resignation on Tuesday, closing a chapter in a curious political saga that threatened to destabilize Lebanon and transfixed the region.

The reversal by the prime minister, Saad Hariri, was considered a setback for Saudi Arabia and its brash young crown prince, Mohammed bin Salman, who had summoned Mr. Hariri to Riyadh last month.

Western diplomats and Lebanese officials have said the prince coerced Mr. Hariri into announcing his resignation and effectively kept him under house arrest for more than two weeks, until an international diplomatic scramble brought him home.

The episode was widely seen as an attempt by Saudi Arabia to counter its regional rival, Iran, by collapsing Mr. Hariri’s government, which includes Hezbollah, the Shiite militia and political party that is Iran’s Lebanese ally.