Media playback is unsupported on your device Media caption Toned-down Trump: What happened to the tough talk on Paris?

President Trump has made a new friend - Emmanuel Macron, the French president. The alliance, say analysts, is good for both Europe and the US.

Trump and Macron sat next to each other and watched a Bastille Day parade on the Champs-Elysees.

Trump put his hand on Macron's shoulder. A moment later Macron placed his hand on the other man's back, a sign of their new friendship.

French and US troops both marched in the parade, honouring the fact that the Americans helped France survive two world wars. More recently French and US militaries have worked together to combat al-Qaeda in West Africa and the Islamic State group in Syria.

Afterwards Trump headed back to the US, and one of his advisors, Thomas Bossert, who was travelling with him, talked about the importance of the friendship between the two leaders.

While the president was in a private cabin on Air Force One, Bossert told me and other reporters on the aeroplane that Trump and Macron would now be able work together more closely on issues such as counterterrorism and defence.

"The relationship that the two presidents has forged will increase the trust that's required" for intelligence sharing and other delicate matters, Bossert explained.

Their friendship came about in a surprising way.

Media playback is unsupported on your device Media caption The US president and his French counterpart shared a handshake that seemed like it would never end

When they met in Brussels in May, Macron gave Trump a manly hand shake, showing he was a force to be reckoned with. Trump also made something clear during his first trip to Europe as president: he expected a lot from his friends.

Trump said that members of the North Atlantic Treaty Organization (Nato) should increase their defence spending. A European official who's close to Macron told me that Trump also shared an idea with them about the contributions to Nato that members make.

The European official said that Trump wanted to present Macron with an invoice on camera as a way of showing that the French should pay more money for their defence.

The Europeans said they did not like the idea of a mini-drama about Nato spending, while a White House official told me the president never suggested it.

Media playback is unsupported on your device Media caption The US president told Brigitte Macron she was "in good shape"

The discrepancy in these two accounts hints at a bigger problem: Trump hasn't gotten along with Europeans. He made disparaging remarks about Nato and pulled the US out of the 2015 Paris climate accord.

Afterwards Macron called Trump, asking him to come to Paris for Bastille Day.

"Macron's invitation to Trump was a bold stroke," said Charles Kupchan, who served as the national security council's senior director during the Obama administration.

Macron's invitation was a subtle form of flattery, a national pastime in France, but in this case there was more than a kernel of sincerity too.

"If Macron is seen to be trying to ingratiate himself, that is in itself flattering," said Richard Stengel, who served as an under secretary of state for the Obama administration and is the author of a book called You're Too Kind: A Brief History of Flattery.

Macron did not agree with much of what Trump has said and done since taking office, but still Macron wanted to get along. France's relationship with the US - for military and other reasons - is considered to be a top priority for Macron and his deputies.

Image copyright EPA Image caption The official visit saw a few protesters

"They need to make sure they don't screw it up," said Jeremy Shapiro, former US state department official.

The charm strategy worked - in part because Macron had a willing victim. Trump likes to single people out in hostile-ish groups and turn them into allies. In Europe, an area filled with leaders who resent Trump, Macron offered hope.

Besides that, as the German Marshall Fund's Alexandra de Hoop Scheffer, said: "Trump has a lot of respect for Macron."

Trump arrived in Paris on Thursday. That evening he and Macron sat at a table in Jules Verne, a restaurant on top of the Eiffel Tower with a spectacular view of the city, and they talked about food.

Watching the Bastille Day parade, Trump spoke to Macron in an animated way, throwing his arms around. The troops wore white gloves and feathered hats, and they carried swords and marched in lockstep. They looked like tin solders come to life, and Trump clapped exuberantly.

Media playback is unsupported on your device Media caption US President Donald Trump attended the parade

Trump has said lots of bad things about Europe, but Macron managed to turn things around.

He gave a speech that afternoon with Trump standing next to him. At the end of his remarks, Macron said: "Vive la France."

It was a European sentiment that Trump - at least for the moment - embraced.