“In France we have the freedom to blaspheme. It is a matter for individual conscience.”

Not many western leaders would have the gall to utter words such as these in the capital of a largely Muslim country – the country, moreover, that is home to Hezbollah, one of the most powerful, and most ruthless, Shia Islamist movements in the entirety of the Middle East.

But that was the message delivered this week in Beirut by Emmanuel Macron. The French President was speaking during his second visit to Beiruit since the massive explosion that last month destroyed the city’s port and devastated much of its downtown area, killing at least 200 people and injuring thousands more.

The context was the trial, opening this week, of those accused of attacking the offices of the satirical weekly Charlie Hebdo in Paris in January 2015. Twelve journalists and other staff of the paper were killed and another eleven seriously wounded in the assault, which followed the publication of cartoons mocking the Prophet Mohammed.

This week, Charlie Hebdo defiantly republished the cartoons as a form of memorial to the victims, and, equally defiant, Macron defended the decision.

Boris Johnson once described Muslim women who wore burqas as looking like letter boxes. But it is unlikely that he would dare to have repeated his slur during a news conference in the Lebanese capital, or anywhere else.

Public opinion in France is divided on the wisdom of the President’s remarks. Less than a year after the attack on Charlie Hebdo, Paris was traumatised by a series of assaults from Islamist terrorists in December 2015, during which 130 people were killed and a further 413 injured. Then, the following year, 87 died and 434 were injured when an extremist at the wheel of a 19-tonne truck drove into crowds of pedestrians on the Promenade des Anglais in Nice.

Memories of these outrages have yet to fade, and there can be few who would wish to provoke a second wave of attacks. But there is also a sense of pride that France did not overreact at the time and that its President is still prepared to stand up and defend the principles of liberty, equality (before the law) and fraternity (between different communities) that, at least in theory, underpin the Republic.

The trial, in the case of the Charlie Hebdo assault, in which 14 people stand accused of murder and conspiracy to murder, has been a long time coming and will not end anytime soon. Much attention will focus on the motives of those alleged to have planned and carried out the raid. More widely, in the court of public opinion, the question will once more be asked, was there among France’s 6-million-strong Muslim community a significant minority who thought that those responsible were in some way justified by the verses in the Quran prohibiting all images of the Prophet.

In Beiruit, meanwhile, Macron continued with his personal mission to catalyse reform of the notoriously corrupt Lebanese government. He and his senior staff have worked assiduously in recent weeks to organise assistance for the city’s two million or more beleaguered residents. An international relief effort was launched by France in the immediate aftermath of the August 4 blast. Since then, Macron has spoken personally to President Trump, EU leaders and the Iranian President, Hassan Rouhani, demanding that they throw their weight behind his programme for fundamental change.

This week, he spoke with each of the factions – Sunni, Shia, Maronite and minority Christian – that currently make up the badly cracked mosaic that is Lebanese governance. He even met with leaders of Hezbollah, who had almost certainly delighted in the terrorist attacks in France, urging them to differentiate between their aspiration to create a Shiite caliphate in the Levant and the need to provide a stable and effective civil administration in Lebanon.

What the long-term result of his intervention will be remains to be seen. Good intentions are two-a-penny in the Middle East and are quickly forgotten. The same is true of “peace plans”. The divide-and-rule factions that have held sway for decades are deeply entrenched. Individuals may come and go (some to jail, others into enforced exile, not a few to their families’ burial plots), but the system, though shaken, never quite collapses.

Macron (with several EU ambassadors trailing behind, muttering support) can at least say that he is trying. The last time the British foreign secretary, Dominic Raab, spoke out on the subject was on August 5, when he promised £5 million in emergency aid and offered help to re-train the Lebanese armed forces. Little wonder that those who are trying hardest to promote reform within Lebanon itself have taken to calling themselves “Macronites”.

Cynics will argue that the French leader at one level almost welcomes the distraction. With Covid-19 continuing to ravage France and with his domestic economic programme effectively on hold, he has ended up like those American presidents (not Donald Trump) who, having expended their ammunition on a series of uncompleted domestic reforms, turn to foreign policy as a means of burnishing their legacy.

Macron would retort that France has a special duty towards Lebanon, which was once a French protectorate and part of its original League of Nations mandate after the end of the First World War. He might also argue that, in addition to his campaign for economic and political reform of the EU, he is also actively engaged in the fight against Islamist forces in West Africa.

He knows, however, that luck is the essential ingredient in French politics and that time is starting to run out if he hopes to rebuild impetus in advance of the next presidential election in 2022.

“It’s the last chance for this system,” he told the news site Politico on Monday. He was talking about Lebanon, but he could equally have been reflecting on his time in the Élysée. “It’s a risky bet I’m making. I am aware of it. I am putting the only thing I have on the table: my political capital.”