Under grey clouds and persistent drizzle, France’s president, Emmanuel Macron, and Germany’s chancellor, Angela Merkel, clasped hands at a solemn ceremony at Compiègne as they marked the centenary of the armistice signing.

It was the first time since 1940 that leaders from the two countries had met at the historic site, where Marshal Ferdinand Foch, supreme commander of the western front, signed the ceasefire agreement with Germany in a railway carriage.

On Saturday, as the French and German national anthems were played, the sun briefly broke through and the chancellor rested her head on the president’s. The two leaders laid a wreath and unveiled a plaque celebrating their reconciliation. They then signed the visitors’ book in a replica of Foch’s railway carriage, known as the Compiègne Wagon, where in an act of revenge Adolf Hitler forced France to sign its capitulation in June 1940.

“We owe it to our soldiers,” said Macron afterwards. Symbolically, he and Merkel sat side by side and not face to face as the French and German representatives had in 1918 and 1940.

After the ceremony both leaders returned to Paris, where the French president hosted a dinner at the Musée d’Orsay for Donald Trump and dozens of other foreign leaders before Sunday’s commemoration ceremony at the Arc de Triomphe.

Merkel and Macron in the replica of the Compiègne Wagon, the railway carriage where the armistice was signed in 1918 and France surrendered in the second world war. Photograph: Philippe Wojazer/Reuters

The US president, who had flown in to the French capital on Friday, had been due to visit the Aisne-Marne American Cemetery on Saturday, where American and French troops repelled the Germans in 1918, but called it off because of the rain.

That sparked incredulity among some of Trump’s critics: Nicholas Soames, the Conservative MP and grandson of Sir Winston Churchill, tweeted: “They died with their face to the foe and that pathetic inadequate @realDonaldTrump couldn’t even defy the weather to pay his respects to The Fallen #hesnotfittorepresenthisgreatcountry.”

The US political commentator David Frum tweeted: “It’s incredible that a president would travel to France for this significant anniversary – and then remain in his hotel room watching TV rather than pay in person his respects to the Americans who gave their lives in France for the victory gained 100 years ago tomorrow.”

In Compiègne, 80 miles north-east of Paris, Jean-Claude Tranchant, one of the French flag-bearers at the ceremony, said he had been marking the armistice for 25 years. “I am very happy Mme Merkel is here today. It is logical that she is with us for the centenary. I think everyone is happy she is here. It’s symbolic for our country and internationally. It’s also important for the younger generation and the future,” he said.

Around 1,000 members of the public were invited to the ceremony, including groups of French and German schoolchildren. High-school student Mickaël Arlin, 16, had been visiting first world war commemorative sites, including Verdun, with a group of German students. “It has helped us understand what is at stake today and helped us go further than just words,” he told French TV.

Marshal Foch, second right, with his entourage after the signing of the armistice in Compiègne. Photograph: Chronicle/Alamy

In November 1918, in the clearing that would become known as the Glade of the Armistice, Foch sat in a dining car that had been converted into an office, with his team, including the British admiral Sir Rosslyn Wemyss. The Germans arrived in another train. After days of talks, the Germans agreed to sign the Armistice at 2.05am, walked a few yards to Foch’s carriage and signed at 5.10am.It was a cold damp morning and the 1,561th day of the war, and the atmosphere inside the carriage was as chilly as outside. When the document was signed, Foch stood but refused to shake hands with the Germans. “Eh bien, messieurs, c’est fini. Allez,” he said. (“So, gentlemen, it’s finished. Go.”)

The Elysée said Merkel’s visit to Compiègne was “highly symbolic”. “It’s the first time French and German leaders have visited the site since the second world war,” the presidential palace said, suggesting the event echoed the moment that chancellor Helmut Kohl and President François Mitterrand appeared hand-in-hand at Verdun in 1984.

German-born Marius Stieghorst, artistic director at the Orléans Symphonic Orchestra, composed a “hymn to peace” to be performed during the weekend commemorations.

“The Great War was above all a war of sounds, the whistling of the shells for example … many soldiers died because they didn’t listen to the sounds,” Stieghorst said in an interview.

He described his emotion at finding a recording of the minutes before and after the armistice. “What we have is one of the great perversities of the war. We hear the sound of ‘normal’ war two minutes before. Everyone knew the war would end, but you hear the exchanges. One minute before there is something unimaginable; everyone, the Americans, Germans, English, French started firing like madmen against the enemy. We hear the greatest chaos you can imagine. I don’t want to know how many soldiers were dead the last minute of the great war, knowing in one minute peace would happen. This was very moving for me. We have done an orchestral improvisation on that moment, to transform that perversity.”

Earlier, in Paris, Macron and Trump had agreed on the need for more European defence spending. The meeting had been expected to be tense after the US president tweeted that Macron’s call for a European army to defend against the Chinese, Russians and Americans was “insulting”. But as the two men met on the steps of the Elysée, both gave the thumbs-up to photographers, and Macron described Trump as “my good friend”.

Afterwards, Macron said the meeting had been “very constructive”. The Elysée insisted Trump had misunderstood Macron’s comments.