President Donald Trump took aim at France and Germany while praising Turkey in a wide-ranging, impromptu press conference Tuesday shortly after arriving in London for a NATO summit.

Speaking alongside NATO Secretary General Jens Stoltenberg, Trump almost immediately took a thinly masked swipe at French President Emmanuel Macron less than a month after France's leader said the world was witnessing "the brain death" of NATO as a result of America's unreliability. Macron's comments came shortly after Turkey invaded northern Syria despite U.S. and other warnings.

"We have tremendous spirit as it pertains to NATO, I would say except for one country," Trump said. When asked about those comments, Trump described Macron's statements as "nasty" and "very disrespectful," and said the U.S. is "going to tax them" – an apparent reference to potential tariffs on French products like wine and cheese in retaliation for taxation on American tech companies.

Political Cartoons on World Leaders View All 72 Images

"Turkey responded by saying he was brain dead, which is interesting," Trump said of Macron's comments. "I think that's very insulting to a lot of different forces, including a man who does a very good job in running NATO."

But Trump, who has previously called the Cold War-era alliance "obsolete," again complained that the U.S. has not been treated fairly by other member countries, which he says have not "paid." NATO countries agreed in 2014 to each dedicate 2 percent of their gross domestic product on defense spending by 2024 – an arrangement Trump frequently represents as some sort of dues each country owes the alliance.

The reference to Stoltenberg prompted the NATO chief to tout the importance of the alliance, and he attributed to Trump what he described as a renewed interest among member states.

"NATO is active, NATO is agile, NATO is adapting," Stoltenberg said, referencing what he described as "the largest reinforcement of collective defense since the end of the Cold War."

The alliance is "also addressing the security implications of the rise of China," Stoltenberg said.

Tuesday's exchange marked a stark departure from what had originally been a warm relationship between Trump and Macron. The two leaders were scheduled to meet later in the day.

In the almost hour-long press availability, the president also took aim at Germany over a particular grievance of his, saying the country should do more to support the alliance as one of its wealthier members.

"So we're paying 4 -4.3 percent when Germany's paying 1-1.2 percent – at max 1.2 percent – of a much smaller GDP. That's not fair," Trump said in an apparent reference to the percentage of GDP each country dedicates toward defense spending.

According to the latest NATO figures, the U.S. spends 3.42 percent of its GDP on defense – a decline from more than 3.5 percent in 2014 – while Germany spends 1.36 percent, a figure that has increased.

Among the countries Trump did not criticize was Turkey, which has intensely strained its relations with the alliance over its decision to purchase Russian anti-aircraft system and to defy American requests not to invade neighboring Syria in October. Analysts believe a series of domestic crackdowns by the administration of President Recep Tayyip Erdogan threatens to undermine the country's democratic system.

However, Trump described it as "a country that I happen to have a good relationship with."

He praised Turkey for allowing U.S. commandos to fly through airspace it controlled on a mission to kill Islamic State group leader Abu Bakr al-Baghdadi and blamed the country's purchase of the Russian S-400 missile system on his predecessor Barack Obama, who conditionally allowed Turkey's purchase of the Russian alternatives to NATO weapons.

He also referenced his goal of remaining in Syria to "keep" the country's oil reserves – a mission the Pentagon has used to justify broader counter-terror operations.

Referring to the decision to withdraw American forces from parts of northern Syria ahead of Turkey's invasion, Trump said, "we did a deal that everybody was very critical of and now they're saying it works."