President Obama meets Saudi King Salman bin Abdul Aziz in Riyadh, Saudi Arabia. (Carolyn Kaster/AP)

For someone who preaches the importance of diplomacy and outreach, even to longtime enemies, President Obama can be awfully tough on his friends.

In recent months, he has offended most of the United States’ Persian Gulf allies. “All I need in the Middle East is a few smart autocrats,” he joked privately, according to a recent profile in the Atlantic magazine. Publicly, he has said he “weeps” for Saudi and Kuwaiti children.

The United States’ European allies, he complains, have grown too dependent on American firepower to keep them safe.

Even the United Kingdom, a U.S. “special” partner, has received criticism. Obama seemed to blame the postwar chaos in Libya on British Prime Minister David Cameron, who he said “became distracted by other things” and didn’t do enough to bring order to the fractious country.

In the next several weeks, Obama will take a series of overseas trips to firm up U.S. alliances and help set the president’s foreign policy legacy. The first of the trips begins Tuesday with stops in Saudi Arabia, Britain and Germany, where the president will tackle an ambitious agenda that includes battling the Islamic State, constraining Iran, sustaining support for sanctions against Russia and warding off a British exit from the European Union.

One big challenge for Obama will be squaring the careful diplomatic rhetoric that’s a standard, and frequently stultifying, part of all presidential visits with his tougher, more honest language from interviews back home.

“Leaders are going to have to deal with that dichotomy,” said Heather Conley, a former State Department official and a Europe analyst at the Center for Strategic and International Studies, “and I don’t believe it’s going to be very easy.”

Even before he became president, Obama introduced himself to the world as a multilateralist who aimed to solve the thorny problems of the 21st century collaboratively. “True partnership and true progress . . . require allies who will listen to each other, learn from each other and, most of all, trust each other,” Obama told adoring crowds in Berlin in 2008.

He followed up that speech one year later in Cairo by quoting verses from the Koran, acknowledging America’s mistakes and calling for a new partnership with the Muslim world “based upon mutual interest and mutual respect.”

Seven years later, the soaring, optimistic language of those early speeches has long since been subsumed by the messy reality of war and diplomacy. Obama has not been able to forge a close rapport with many world leaders.

The president’s cold-eyed view was apparent last year after the attack on the Charlie Hebdo satirical weekly by two militant gunmen. World leaders from Germany, France and Britain marched through the streets of Paris with longtime adversaries such as the Israeli prime minister and the head of the Palestinian Authority. No senior official from the United States marched with the European leaders, prompting a rare apology from the White House.

“I’ve never heard that Obama has a personal relationship with any of them,” said Xenia Wickett, head of the Americas program at the London-based think tank Chatham House. “It is neither hot nor cold. There is no personal relationship.”

For Britons especially, that’s a break from a long history of starry-eyed relationships between leaders across the Atlantic. Roosevelt and Churchill. Reagan and Thatcher. Bush and Blair. Obama, the mixed-race child of a single mother, and Cameron, a stockbroker’s son with royal lineage, have never had the same kind of personal chemistry.

Obama’s cool relations with European leaders is partly a product of his style — even in Washington, the president is known for his frosty relationship with fellow Democrats and big donors. He disdains neediness and sometimes struggles to empathize with allies. It’s also a product of an era in which Western leaders have been focused inwardly on domestic politics.

“Who are Cameron’s close re­lationships with? Who are Merkel’s? Or Hollande’s?” Wickett asked, referring to the British, German and French leaders. “We’re just not as focused on one another in the same way that we might have been historically.”

One big question is whether Obama’s lack of personal ties to his fellow world leaders is hindering his foreign policy. The primary cause of the strain between Obama and Arab allies is rooted in big differences over how to deal with the collapse of autocratic governments and huge refu­gee flows.

The United States’ Persian Gulf allies have lambasted Obama for not doing enough to confront Iranian aggression or to stop Syria’s bloody civil war. “This policy has led to increased chaos and bloodshed,” Nawaf Obaid, special counselor to the Saudi ambassador to the United Kingdom from 2011 to 2015, wrote recently in the National Interest magazine.

The president’s tough, and unprecedented, critique of longtime Arab allies has not helped in the search for common ground. Nor has the bitter and divisive presidential campaign in which all of the major Republican presidential candidates have called for barring the refugees of Syria or other majority-Muslim countries from entering the United States.

“It’s clear that the president’s cerebral, dispassionate approach isn’t well suited to the gulf leaders,” said Perry Cammack, a former State Department official in the Obama administration and associate at the Carnegie Endowment for International Peace. “The end of the Obama administration can’t come quickly enough for these leaders.”

In Europe, where Obama remains popular with the public, his tough-love approach has been less of a handicap. A Pew Research Center survey last year showed that about three-quarters or more of voters across France, Germany and Britain trusted Obama to do the right thing — a lofty status that is down only slightly from his first year in office.

Often, Obama seems a bit bored by issues on the continent. Still, Europeans like Obama’s deliberative, rational, technocratic style. “He looks and smells like a European,” Wickett said.

When Obama appeared to lash out at Cameron in the Atlantic magazine article, saying the British leader had become distracted after the Western air campaign in Libya, the remarks fed a few days of headlines in Britain.

But the controversy quickly faded, and the close cooperation between the two governments moved forward without a hiccup.

“The so-called special relationship isn’t about how Thatcher and Reagan get on,” said Walter Ladwig, a professor at King’s College London. “When you get under the hood of intelligence networks, for instance, in some respects the British and American operations are inseparable. And that kind of cooperation continues irrespective of whether Barack and Dave are grilling hot dogs together.”

Still, when Obama is standing with the Saudi king, the British prime minister or the German chancellor, talking about their countries’ enduring alliance, it’s possible that some may be thinking back to an interview the president did late last year with comedian Jerry Seinfeld.

“How many world leaders do you think are just completely out of their mind?” Seinfeld asked Obama.

“A sizable percentage,” the president replied without missing a beat. “Some of these people, you meet them, you’ll just be chatting and you look in the eyes and go, ‘Oh, this guy’s gone.’ ”

Witte reported from London.