His trip comes days after Lebanese PM Saad Hariri resigned while in Riyadh, saying he feared for his life.
Foes Saudi Arabia and Iran have accused each other of fuelling instability in Lebanon and the wider region.
Mr Macron and Saudi officials also discussed the crisis in Yemen, where Riyadh is leading a war against rebels.
France has historical ties with Lebanon, as its former colonial power before it gained independence during World War Two.
The French president was in the United Arab Emirates on Thursday to open the Louvre Abu Dhabi, a spin-off of the famous Paris art museum.
Speaking there, he announced his unexpected two-hour trip to Riyadh to hold face-to-face talks with Saudi Crown Prince Mohammed bin Salman, and "emphasise the importance of Lebanese stability and integrity".
"My wish is that all Lebanese political officials live freely in Lebanon... which means having a very demanding stance on those who could threaten any leader", he added.
Saudi Arabia's blockade on Yemen was tightened on Monday after a missile was fired from Yemen at the Saudi capital, Riyadh - which the Saudi government blamed on Lebanese militant group Hezbollah and its chief backer Iran.
The missile was intercepted near the Saudi capital.
The UN has warned that Yemen faces the world's largest famine in decades "with millions of victims" if the blockade is not lifted and aid deliveries are not resumed.
In a separate development on Thursday, Saudi Arabia told its citizens in Lebanon to leave the country immediately.
There are fears Lebanon could become embroiled in a wider regional confrontation between major Sunni power Saudi Arabia and Shia-dominated Iran.
Mr Macron is a keen supporter of the 2015 Iranian nuclear deal, which both the Saudis and the Trump administration have heavily criticised.
Ahead of his visit, Mr Macron said that he had heard "very harsh opinions" on Iran from Saudi Arabia, which did not match his own view. "It is important to speak with everyone," he added.
But an official communiqué from his office following the visit did not mention Iran at all, French newspaper Le Monde reported.
The French president added that he had been in informal contact with Saad Hariri.
Mr Hariri's resignation has created deep uncertainty in Lebanon
Mr Hariri said in a TV broadcast on Saturday that he was stepping down because of an alleged assassination plot.
In the video statement, Mr Hariri also attacked Hezbollah, which is politically and militarily powerful in Lebanon, and Iran.
Mr Hariri's father and former prime minister Rafik was killed by a bomb in 2005 in an attack widely blamed on Hezbollah.
Mr Hariri has made no further statement so far, but his office says he has been having meetings with foreign diplomats in Riyadh.
Hours later Saudi Arabia's neighbouring Gulf state and ally Kuwait issued a similar statement.
But Hezbollah accused the Saudis of orchestrating Mr Hariri's resignation. Saudi Arabia, in turn, has accused Hezbollah of launching the missile intercepted near the Saudi capital from Yemen.
A day later Crown Prince Mohammed bin Salman accused Iran of "direct military aggression" by supplying missiles to Houthi rebels in Yemen.
Iran has dismissed the Saudi allegations as "false and dangerous".