The soldiers stood at attention, rifles at their sides, as U.S. Army Maj. Gen. David Hogg walked down the ranks, eyeing the men heading off to fight in Somalia.

"You will push ... the miscreants from that country, so Somalia can once again be free of tyranny and terrorism," he told them, according to a video of the May ceremony. "We know you are ready."

These weren't American soldiers. They were from impoverished Sierra Leone in West Africa. But Hogg, a top U.S. Army commander for Africa, was in Freetown, Sierra Leone's capital, because this was largely an American operation.

Nearly 20 years after U.S. Army Rangers suffered a bloody defeat in Somalia, losing 18 soldiers and two Black Hawk helicopters, Washington is once again heavily engaged in the chaotic country. Only this time, African troops are doing the fighting and dying.

The United States is doing almost everything else.

The U.S. has been quietly equipping and training thousands of African soldiers to wage a widening proxy war against the Shabab, the Al Qaeda ally that has imposed a harsh form of Islamic rule on southern Somalia and sparked alarm in Washington as foreign militants join its ranks.

Officially, the troops are under the auspices of the African Union. But in truth, according to interviews by U.S. and African officials and senior military officers and budget documents, the 15,000-strong force pulled from five African countries is largely a creation of the State Department and Pentagon, trained and supplied by the U.S. government and guided by dozens of retired foreign military personnel hired through private contractors.

Like CIA drone strikes in Pakistan and Somalia, and the overthrow of Moammar Kadafi's regime in Libya, the U.S. backing of African troops in Somalia is an example of how, after a decade of ground combat in Iraq and Afghanistan, the Obama administration is trying to achieve U.S. military goals with minimal risk of American deaths and scant public debate.

The U.S. can underwrite the war in Somalia for a relative pittance -- the cost over four years has been less than $700 million, a tenth of what the military spends in Afghanistan in a month -- but the price tag is growing. More than a third of the U.S. assistance has been spent since early 2011.

A shadowy organization estimated to have as many as 14,000 fighters, the Shabab emerged in 2007 when it vowed to overthrow the weak fledgling central government in Mogadishu, the capital. The militia gradually took control of large parts of the capital and other towns, defeating some of Somalia's well-armed clans and allying with others. U.S. officials say its ranks include foreigners linked to Al Qaeda, which the Shabab announced it had joined this year, and they worry that Al Qaeda could gain a larger foothold in Somalia unless the homegrown group is defeated.

The administration has not disclosed much in public about its role in Somalia, in part because African Union officials do not want their force seen as a Washington puppet. But Wafula Wamunyinyi, deputy head of the African Union mission, calls the U.S. "our most important partner," noting that its assistance has been "quite enormous."

The U.S. is supplying the African forces with surveillance drones, ammunition, small arms, armored personnel carriers, night-vision goggles, communications gear, medical equipment and other sophisticated aid and training, documents show.

Before the soldiers deploy, they receive boots, uniforms, protective vests and 13 weeks of basic training in combat skills and detecting hidden bombs. There's also more specialized instruction for medics, intelligence officers and combat engineers.

That may not be enough, according to some African officers who contend that the U.S. must do more if it expects the troops, many of whom are experienced at bush fighting, not counterinsurgency, to defeat the Shabab.

"The U.S. government has done extremely well in providing for us and we are grateful for that, but they can do more," Brig. Gen Komba Mondeh, Sierra Leone's chief of operations and plans, said in an interview. "This is real war, and we expect to see the body bags coming back home."

Dozens of African Union troops have already died. But their efforts have achieved substantial success, at least recently. Last August, the 9,800 troops from Uganda and Burundi that for years had been battling the Shabab for control of Somalia's capital finally drove out the militants. In June, the troops took Afgooye, a key town in the southeast.

The mission could still go badly wrong. In 2006, Washington backed Ethiopia's invasion of Somalia, which aimed to drive the precursor to the Shabab from power.

The Ethiopian forces quickly captured Mogadishu, then became targets of insurgent attacks. Ethiopia withdrew most of its forces three years later, leaving behind an even more powerful Islamic movement.

The latest effort has a better chance of success, U.S. officials say, because most of the African troops are not drawn from Somalia's immediate neighbors and are operating under the African Union banner; they are perceived more as peacekeepers than occupiers. To actually stabilize the country, however, will require building a working Somali central government, a task that remains far off.

"You can win the war, but without political stability, you will not have won," Wamunyinyi said.

Meanwhile, the force is growing. In October, Kenya sent several thousand troops into southern Somalia, which later were incorporated into the U.S.-backed mission. This month, an 800-strong battalion from Djibouti arrived, to be followed by the Sierra Leone battalion in early September.

By itself, Sierra Leone's ragtag military, which has no air force and little working equipment, would have been incapable of sending soldiers across the African continent for a yearlong deployment. Its battalion will be flown to Kenya to pick up vehicles paid for by the U.S. that are being shipped there from South Africa.

After driving across the border, the troops plan to link up with Kenyan forces, who have been bogged down in the south since their invasion. Their objective will be to flush Shabab fighters out of Kismayo, a strategic port city in the south. Meanwhile, the main African Union forces in Mogadishu have been extending their operations into the countryside.

No U.S. military personnel are deployed to Somalia with the African troops. Instead, the State Department pays a private firm to hire the retired foreign military personnel who advise the troops on tactics and operations.

"The U.S. is willing to be very open-minded about whatever the key components are that need to be funded, without which this mission would fail," said Michael C. Stock, president of Bancroft Global Development, the Washington-based company that hires the combat advisors. "When it comes to things like ammunition, when it comes to the mentoring and advising that we do, the U.S. is really playing the most important role."

Bancroft now has about 75 advisors in Somalia, double the number from a year ago, Stock said.

The only major part of the Somalia operation that the U.S. doesn't supply or pay for are the troops' salaries and logistical expenses, officials say. Those are handled by the European Union and the United Nations, although the U.N. contribution is partially funded by U.S. dues. Only Washington is willing to provide lethal aid, officials and contractors say.

"It's incredible bang for the dollar that we've gotten," said Michael Bittrick, a State Department official who oversees the effort. "It isn't just about getting infantry shooters to go do their work. We're training their intel people, we're training their indirect fire people, we're training their medical people, we're training their engineers."

That training is done mostly by U.S. contractors and small teams of American military personnel before the troops deploy from their home countries. But the military also brings African soldiers to the U.S. for training.

In December, the Pentagon brought eight Ugandan soldiers and one of Bancroft's advisors to Redstone Arsenal in Huntsville, Ala., to train them to use the Army's Raven drone. The hand-launched, propeller-powered drone beams live video back to a laptop computer when used on the battlefield, as it was last month in Afgooye.

But the force still lacks helicopters and enough heavily armored personnel carriers to protect against the buried bombs that have been a prime weapon of the Shabab. Nor does it have good intelligence on the whereabouts of the Shabab's key leaders and Al Qaeda fighters, though the CIA and U.S. special forces are flying armed drones and other aircraft over Somalia looking for them, the officers say.

There are no plans for the U.S. to provide the African force with helicopters, according to a State Department official. Uganda has promised to provide three helicopters from its tiny air force. Its government has been unwilling to use them in Somalia unless reimbursed for the costs, a matter that remains under negotiation, the official said.

As for armored personnel carriers, "we have a serious shortage, but the U.S. and other partners are working on providing that," said Wamunyinyi, the African Union mission deputy chief.

The U.S. has provided Burundi with a dozen heavily armored troop carriers similar to those used by American troops in Afghanistan, and Uganda brought its own tanks to Somalia, but more are needed for the growing force, officials said.

This week, the Pentagon approved the latest $41-million aid package to African countries with troops in Somalia, with little public notice. Uganda, with the largest contingent, received $19.5 million for "vehicles, small arms, boats, night-vision devices, communications and electronic equipment, training and minor military construction" for its forces. Burundi was given $13.2 million for vehicles and other gear, and Kenya received $7.1 million for eight handheld drones and training.

Army Gen. Carter Ham, who heads the Africa Command, alluded to the U.S. support for countries with forces in Somalia in a speech to African military officers and officials last month in Washington, but did not go into detail about the extent of the U.S. assistance.

"We think that's an ideal role for the United States -- not a large U.S. military presence ... but rather applying the resources that we do have to help those countries who are willing to contribute to this effort," he said.