Theresa May has paid tribute to first world war soldiers who died at the Somme, as she joined the French president, Emmanuel Macron, on his armistice commemoration tour, where he warned that Europe must stick together as nationalism threatens the continent’s fragile peace.

While negotiators in Brussels race to try to reach agreement on Britain’s exit from the European Union, the British prime minister arrived in the small northern town of Albert in the Somme. She looked relaxed and smiling as she was greeted by Macron, who has maintained a firm line on protecting the EU’s founding principles as the UK departs.

After a warm handshake, May followed Macron up the town hall steps for a working lunch to discuss what advisers termed “international issues”. French schoolchildren waving British and French flags shouted: “Good luck!”

French organisers had artfully placed the European Union flag between the British and French flag on the town hall’s steps, reinforcing the bloc’s importance to the pro-European Macron.

Macron and May were keen to demonstrate a close relationship. Macron was working hard to be hospitable, possibly making up for his absence the last time May was in the Somme for a memorial. Macron, although born and raised in the nearby city of Amiens, was not present this summer at Amiens cathedral when May and Prince William commemorated a decisive battle of the western front.

The British foreign secretary, Jeremy Hunt, had arrived in Paris days before May to insist that Franco-British relations – which are extremely close in many areas, particularly defence – would not be harmed by Brexit. The French senate may have passed emergency legislation to cover any problems if there is a no-deal Brexit next March, but local politicians and businesses, particularly in this area of northern France close to the Channel, are keen for an exit deal to be struck.

May and Macron commemorated their countries’ shared sacrifice in the first world war by jointly laying a wreath at the memorial in Thiepval, dedicated to men from British and Commonwealth forces who died in the battle of the Somme. The memorial commemorates 72,337 missing British and South African servicemen who died in a series of brutal battles along the Somme river and who have no known grave.

Macron has said that growing up in the Somme, an area full of war cemeteries, strengthened his view that the EU was a vital block against nationalism. He had a British great-grandfather who fought at the Somme and was decorated for bravery.

Earlier, May had joined the Belgian prime minister, Charles Michel, at Saint-Symphorien military cemetery on the outskirts of Mons in western Belgium to lay wreaths at the graves of the first and last British soldiers to be killed during the conflict.

“A century ago, British forces fought side by side with our allies in Europe on the western front. Today in France and Belgium we reflect on our shared history, but also look ahead to our shared future, built on peace, prosperity and friendship,” May said in a statement.

May’s France visit marked the start of a frantic weekend of armistice diplomacy for Macron. The US president, Donald Trump, was to land in Paris on Friday night and hold talks with Macron ahead of a Sunday ceremony at the Arc de Triomphe in Paris, attended by dozens of world leaders including Russia’s Vladimir Putin and Recep Tayyip Erdoğan of Turkey.

On Sunday, Macron, the German chancellor, Angela Merkel, and the UN general secretary, António Guterres, will join other world leaders and representatives of civil society for a peace forum held in the north-east of Paris. Neither Trump nor May will be present.

Macron has spent a week touring first world war battle sites and towns in northern France. This was in part aimed at reconnecting with the people as his approval ratings have dropped amid criticism that his vow to transform a France blighted by mass unemployment has not fully addressed the concerns of those on low wages.

Just before Macron and May arrived at Albert town hall, a dozen peaceful protesters shouting “Macron resign!” were removed from sight by riot police.