The last time Prime Minister Saad Hariri of Lebanon visited Saudi Arabia, he was stripped of his cellphones, insulted by royal guards, confined and ordered to speak to his Lebanese compatriots on live television and resign.

Four months later, Mr. Hariri is back in Saudi Arabia, apparently on much better terms.

Invited on Monday by King Salman of Saudi Arabia, Mr. Hariri arrived on Wednesday, conferring with the king as the Saudi news state media showed them smiling together at Al-Yamamah Palace in Riyadh, the capital.

A statement by Mr. Hariri’s press office in Beirut said his meetings with the king, who was joined by a retinue of Saudi aides, including the interior and foreign ministers, “focused on the bilateral relations and the latest developments in Lebanon.”

Mr. Hariri was also expected to meet with the king’s son, Crown Prince Mohammed bin Salman, the most powerful figure in Saudi Arabia, who is regarded as the architect of the Lebanese leader’s disastrous November visit.