Even in a part of the world where tangled alliances are as common as sweet tea, one would be hard-pressed to find a country where the same few sweltering square miles house the sprawling operations hub for a huge U.S.-led air war and provide plush sanctuary to the likes of the Taliban and Hamas, both deemed terrorist groups by Washington.
Perched on a tiny peninsula protruding into the Persian Gulf, Qatar is dwarfed by neighbors such as Saudi Arabia, but has displayed outsize foreign policy ambitions, with the ripple effects of its immense natural gas wealth being felt from the mosque minaret to the executive suite, and on battlegrounds from Libya to Syria and beyond.
The emirate's goal may have been to heighten its influence and prestige by extending a cordial hand to all, but falconry-loving Qatar has lately seen its wings clipped, facing bruising rebukes from its powerful neighbors and Egypt over its long-standing support of Islamist groups, some of them militant ones.
Qatari officials used to have a favorite phrase, that the emirate was punching above its weight. Now the watchwords may be more along the lines of quiet retrenchment.
Amid what had become a rapidly deepening diplomatic isolation in the region, Qatar has scrambled to get back in the good graces of the six-nation Gulf Cooperation Council and to mend fences with Egypt, the Arab world's most populous country and its traditional intellectual center.
The emirate has made symbolic steps such as the never formally acknowledged ejection of seven Egyptian Muslim Brotherhood figures, who departed in September for Turkey. It has also moved to stem the flow of funds from wealthy private donors to extremist militantgroups, some via what had heretofore been lightly regulated charities.
Neighbors Saudi Arabia, the United Arab Emirates and Bahrain, which had withdrawn their ambassadors in a highly public sign of strong displeasure, announced two months ago that they would send their envoys back.
Egyptian officials suggest that President Abdel Fattah Sisi, who was infuriated by Qatar's support for toppled Islamist President Mohamed Morsi, may soon be ready to resume high-level contacts. The likelihood of rapprochement increased recently after Qatar acceded to Cairo's demands to shut down the Brotherhood-boosting Egyptian arm of the emirate's flagship broadcaster Al Jazeera, itself conceived as a projection of Qatari power and prestige, but whose influence has waned in recent years.
Despite conciliatory gestures, however, analysts say Qatar has not wavered in its core belief that political Islam — the view that austere Muslim teachings should guide all aspects of society — remains the prime long-term force in the region.
Qatar has faced Western pressure over material support it has provided for some radical factions battling Syrian President Bashar Assad, including Al Qaeda-linked Al Nusra Front, and for siding with a self-proclaimed but not internationally recognized Libyan government aligned with Islamist militias from the western city of Misurata.
"They made the wrong call in a number of places, and there's some recognition of that," said analyst Michael Stephens, deputy director of the Qatar branch of the Royal United Services Institute, a British think tank. "But their fundamental views on political Islam have not altered."
At the other end of the spectrum, the most potent emblem of Qatar's desire to maintain friendly ties with the West has been throwing in its lot with the U.S.-led coalition confronting the Sunni Muslim extremists of Islamic State. But it plays a supporting role, albeit a crucial one, instead of conducting airstrikes.
Qatar's 34-year-old emir, Sheik Tamim bin Hamad al Thani, described by Western diplomats as proving himself a quick study so far in his 19-month tenure, has offered a tellingly nuanced view of the emirate's strategy.
"We don't fund extremists," he told CNN's Christiane Amanpour in the fall. But he said it would be a "big mistake" to brand all Islamist movements as extremist, and defended dealings with groups such as Hamas and the Brotherhood on the basis of their electoral successes in Gaza and Egypt.
Because of those links, the Qatari partnership with the United States is sometimes complicated but clearly beneficial to both sides. "Our interests converge in many more ways than they diverge," said a senior U.S. official, who asked to remain anonymous because of the perceived sensitivity of the subject.
The emirate's role as an interlocutor with militant movements has often proved a useful asset. Together with Turkey, Qatar was a principal pipeline to Hamas during talks to end the group's war with Israel in the Gaza Strip during the summer.
In addition, it helped broker the freeing of five Taliban militants incarcerated at Guantanamo Bay, Cuba — who took up residence in Doha — in exchange for captured U.S. soldier Bowe Bergdahl.
The emirate also engineered last year's release of an American journalist, Peter Theo Curtis, who had been held hostage in Syria, a lucky exception to last year's grisly parade of beheadings of Western reporters and aid workers by Islamic State.
At Al Udeid Air Base on the outskirts of Doha, Qatar's capital, deference to Qatari sensitivities is much in evidence despite the overwhelming American footprint. The base is Qatari-owned, its U.S. personnel constantly emphasize, with access by outsiders vetted by the Qatari bureaucracy.
The installation in many ways resembles American-run military bases anywhere, with fast-food outlets and a staggering array of familiar U.S. goods on offer at the general store. But here, force strength is a matter to be negotiated with the emirate, not dictated by the Pentagon. Coalition pilots even undergo Qatari customs checks when flying combat sorties from the base.
Around the clock, the dusty air is filled with the near-constant roar from the flight line, from which 300 or more missions are launched daily, many on bombing raids against Islamic State positions in Iraq and Syria, but also to destinations spread across the Middle East, North Africa and Central Asia.
The humming command center — and the base as a whole — is a kind of low-slung, high-tech Tower of Babel, even though English, the language of aviation, is the lingua franca. U.S. Air Force Col. Tadd Sholtis, a spokesman for the Air Force's Central Command, said Al Udeid's importance as a forward headquarters is obvious, but "maybe more important is its role as a location where military professionals from many nations and services can come together."
It can be jarring, nonetheless, to drive the short distance from a military installation bristling with U.S. Patriot antimissile batteries into Doha, where Hamas leader Khaled Meshaal's walled villa lies in the same pleasant bougainvillea-dotted neighborhood that is home to a number of diplomats, including the U.S. ambassador.
Another long-term guest is Yusuf Qaradawi, 88, an Egyptian-born cleric who recently landed on Interpol's wanted list, largely at Egypt's insistence. Qaradawi lost his electronic pulpit when his much-watched show "Sharia and Life" was dropped by Al Jazeera last year, but he still has nearly a million Twitter followers, and Qatari officials have made it clear that he remainswelcome.
Like most of its Sunni neighbors, Qatar has no wish for home rule based on a strict interpretation of Islamic law, or for any challenge to its hereditary monarchy. Although social mores are conservative, with most women adopting the face-covering niqab, the emirate accepts differing cultural practices by expatriates. Alcohol is served in the many five-star hotels, and Westerners in casual and sometimes revealing dress are a common sight in the capital.
The emirate's population is about 2 million, but only 300,000 are citizens, a population equivalent to a small city — a small but and extremely, extremely rich one. Even with a large and poorly paid workforce, mainly from South Asia and sub-Saharan Africa, that labors away on gargantuan infrastructure projects, Qatari per capital income is by some estimates the highest in the world.
Combined with Qatar's extreme wealth is a local habit of casually carrying around what most Westerners would consider an outlandish amount of cash. It wouldn't be unusual, one diplomat said, for a Qatari shopping in a boutique-studded mall to spot a donation stand for a charity claiming to fund Syrian relief efforts, and impulsively pop $15,000 into the collection box.
The result is a labyrinthian money trail that perhaps not even the Qataris themselves can accurately follow.
From the outside, the dynamics of Qatar's external relations can appear puzzling and contradictory, but close observers see a distinct internal logic.
"Sometimes you see alliances based on 'the enemy of my enemy' concept, with the idea of playing one ally off against the other," said a Western diplomat who spoke on condition of anonymity because he was not authorized to publicly discuss the emirate's regional dealings.
"It's more," he said, "along the lines of: 'Just because the two of you are enemies, there's no reason I can't be friends with both of you. Because I might need you one day.'"