President Barack Obama is frustrated with America's allies who turn to the United States for assistance but don't always want to help shoulder the burden — financial or otherwise — of dealing with urgent global threats.

In some of his bluntest comments yet on the subject of foreign policy, Obama told The Atlantic that he warned Great Britain that it would no longer have a "special relationship" with the U.S. if it did not start spending at least 2 percent of its GDP on defense.

It was previously reported that Obama spoke with Prime Minister David Cameron about England's military spending during last year's G7 summit.

"Free riders aggravate me," Obama said in a wide-ranging interview with The Atlantic that was published online Thursday and will be featured in its April issue.

Obama said he has struggled to get other nations to take the lead and pull their weight when necessary on several issues — including terrorism, Russian incursions and Chinese aggression.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

Jeffrey Goldberg, who conducted the interview, said the president was especially perturbed when The New Yorker reported, citing an anonymous administration official, that the White House was "leading from behind" amid the Libya crisis of 2011.

"We don’t have to always be the ones who are up front," Obama told Goldberg, the magazine’s national correspondent. "Sometimes we’re going to get what we want precisely because we are sharing in the agenda. The irony is that it was precisely in order to prevent the Europeans and the Arab states from holding our coats while we did all the fighting that we, by design, insisted" they lead during the mission to oust longtime dictator Moammar Gadhafi. "It was part of the anti–free rider campaign."

Obama held up Britain and France as examples of nations who seemed resistant to stepping up wholeheartedly at that time.

He said Cameron became "distracted by a range of other things," while former French President Nicolas Sarkozy "wanted to trumpet the flights he was taking in the air campaign (in Libya), despite the fact that (the U.S.) had wiped out all the air defenses and essentially set up the entire infrastructure" for the intervention.

Obama also questioned America's relationship with the oil-rich kingdom of Saudi Arabia, which has played a pivotal role in the Middle East as a U.S. ally — and Iran's archrival.

He said he did not want to throw "our traditional allies overboard," but that the Saudis will need to get along with Iran for the sake of extended peace.

"The competition between the Saudis and the Iranians — which has helped to feed proxy wars and chaos in Syria and Iraq and Yemen — requires us to say to our friends as well as to the Iranians that they need to find an effective way to share the neighborhood and institute some sort of cold peace," Obama said.

The Atlantic piece also revealed that Obama has likened the entire Middle East to Gotham, the metropolis in the "Batman" comics, and said ISIS was akin to the Joker from the 2008 movie "The Dark Knight," according to advisers.

"There’s a scene in the beginning in which the gang leaders of Gotham are meeting,” the president has said, according to The Atlantic. "These are men who had the city divided up. They were thugs, but there was a kind of order. Everyone had his turf. And then the Joker comes in and lights the whole city on fire. (ISIS) is the Joker. It has the capacity to set the whole region on fire. That’s why we have to fight it."

Related: Obama Meets New Saudi King for Strategic Talks and to Strengthen Ties

The president was also introspective of what he's accomplished in his foreign policy efforts so far. He told The Atlantic that he realizes that historians will one day question his decision to not bomb Syria in 2013 after it appeared Damascus had violated his so-called "red line" against using chemical weapons.

But of that decision, he said, "I’m very proud of this moment. ... The perception was that my credibility was at stake, that America’s credibility was at stake. And so for me to press the pause button at that moment, I knew, would cost me politically."