In the past four years, the Pentagon and State Department have forged a close, and largely unreported, alliance with the Ugandan military. A force of 120 American advisers based in Uganda provides training, weapons and supplies – $100 million worth since 2011 – and in exchange Ugandan soldiers bear the brunt of the close fighting in Somalia, a stronghold for Islamic militants.

The Ugandans' "superb" fighting ability "was directly responsible" for driving militants out of Somalia's capital city of Mogadishu this year, according to one American official close to the U.S. train-and-equip program. But there's a ticking time bomb inside the outwardly strong alliance. Uganda's escalating crackdown on its gays, lesbians and transgenders has the U.S. indicating that it might just cut off that military aid. "LGBT issues" are a "caveat on U.S. support," says the official, who spoke to Danger Room on condition of anonymity.

Uganda's gays, lesbians and transgenders have long faced persecution. Homosexuality has been against the law since Uganda's colonial days. But twice in recent years hardline legislators have proposed laws that would make homosexuality a capital offense. These so-called "Kill the Gays" bills have drawn harsh criticism from Washington and other governments. The official White House strategy for Sub-Saharan Africa, released this month, specifically prioritizes human rights, including "opposing discrimination based on disability, gender or sexual orientation."

As Kampala cracks down on the LGBT community, the American military has grudgingly embraced it. President Barack Obama ended the '90s-era Don't Ask, Don't Tell law in 2010, a move that top Marine general James Amos called a "non-event." Today the military reacts swiftly to punish gay-bashing. And in a landmark event this week, the Pentagon officially celebrated its gay and lesbian troops.

The growing LGBT schism between the U.S. and Uganda threatens one of the most remarkable alliances in recent years. Since the deaths of 18 American troops in Mogadishu in 1993 – the Black Hawk Down incident – the U.S. has been reluctant to deploy significant forces onto Somali soil, even as Islamic militants took advantage of a devastating civil war to seize huge swaths of the East African country.

Instead, Washington recruited proxy armies to do American bidding in Somalia. The Pentagon's direct involvement includes naval bombardments, air strikes and deadly commando raids launched from a constellation of secret bases. But U.S.-trained and -supported African troops do most of the hard fighting, and almost all of the dying, in the grinding battle against Somali Islamists. America's Somalia intervention isn't just a shadow war – it's a proxy shadow war.

Starting in 2007, the U.S. government footed the bill for an African Union force comprising thousands of Ugandans, Burundians, Djiboutians and other African nationalities. The Ugandans provided the battlefield commanders and operated most of the heavy weaponry, including T-55 tanks. The AU troops stormed Mogadishu and, at the cost of 500 deaths, gradually recaptured the ravaged city over a period of five years. None of the supporting U.S. troops have died in combat, though accidents in the region have claimed several American lives.

The official sees a bright future for U.S.-backed security operations by Kampala. The country is "well on its way" to becoming the second-most powerful in East Africa, after Ethiopia, the official says, adding that U.S. support will remain "at a high level" as long as Ugandans are shouldering the major burden of fighting in Somalia. Ugandan troops are already helping in U.S. efforts to track down the Lord's Resistance Army rebel group in Congo.

Meanwhile, an empowered Uganda could front American efforts in another possible war in Africa. Like the U.S., Uganda strongly supports an independent South Sudan as a bulwark against aggression by Khartoum. "They [the Ugandans] will, without question, intervene if Sudan invades and threatens Juba," the official says. To prepare for combat with Sudan, the Ugandans spent hundreds of millions of dollars of their own money on a fleet of Russian-made Su-30 fighters, giving them the most powerful air force in the region ... and an important proxy asset for the U.S.

But Kampala's persecution of gays could compel Washington to end the alliance before it has a chance to expand beyond the Somalia campaign.