United Nations: Qatar’s growing clout and its alliance with the United States has won it diplomatic leeway from Washington.

When Turkey’s prime minister announced plans to visit the Gaza Strip recently, American officials made clear they opposed any engagement with Hamas, the Palestinian group that controls the strip.

When Qatar’s emir visited Gaza last month, pledging hundreds of millions in reconstruction aid, the State Department was understanding. “The Qataris have described this as a humanitarian mission,” spokeswoman Victoria Nuland said. “We share Qatar’s deep concern for the welfare of the Palestinian people, including those residing in Gaza.”

Qatar has long sought to cultivate a reputation as a country interested in serving the public good. Qatar’s cultivation of African Islamists, principally Somalia’s Al Shabab insurgents, has similarly troubled the United States, which has accused the movement of providing a haven for Al Qaida militants involved in attacks against Americans.

In 2009, Somalia’s then-president, Sharif Ahmed, told a top US diplomat that Qatar was channelling financial assistance to Al Shabab via Eritrea, according to a US diplomatic cable disclosed by WikiLeaks.

Several weeks later, Susan Rice, the US ambassador to the United Nations, urged Turkey to press Qatar to end its support for Somali insurgents.

Qatar denied the accusation. “They understand they’re walking a tight rope and they have been able to get away with it because they have tended to the relationship and have tried to be useful when interests converge,” said Michael Hanna, an expert on the Middle East at the Century Foundation.

Although the Qataris are committed to backing secular academic institutions, there is “clearly an Islamist bent to their foreign policy,” said Gregory Gause, an expert on the Gulf region at the University of Vermont who served as a non-resident senior fellow at Brookings Doha Centre.

“They have made a decision: ‘If we are going to play, we are going to be with the people on the rise and that is the Islamists,” he said. At the same time, the Qataris know they remain key to U.S. military efforts in the region. “That is their ultimate security guarantee and their entryway into the highest levels of American policymaking, which is why they can be so aggressive,” Gause said.