NEW YORK (Reuters) - Two Swedish citizens who U.S. prosecutors said fought alongside the Islamist militant group al Shabaab in Somalia in battles to take control of the country’s capital of Mogadishu were sentenced to 11 years in prison on Friday.

Ali Yasin Ahmed, 31, and Mohamed Yusuf, 33, were sentenced by U.S. District Judge John Gleeson in Brooklyn, New York, in light of their guilty pleas in May to conspiring to provide material support to al Shabaab.

Prosecutors had sought 15 years in prison for the Somali-born men, who they called “operational members of a terrorist organization.”

But while Gleeson said that was correct, he said he also partly accepted their lawyers’ characterizations of the men as freedom fighters who only joined al Shabaab in order to return to war-torn Somalia to fight against Ethiopia.

“This is not a black-and-white situation,” Gleeson said.

Prosecutors said Ahmed and Yusuf abandoned their homes in Sweden in 2008 to travel to Somalia to undergo military and doctrinal training with al Shabaab.

The militant group, which seeks to overthrow Somalia’s Western-backed government and impose a strict version of sharia, or Islamic law, has links to al Qaeda and has carried out attacks in Kenya and Ethiopia.

After receiving training, Ahmed and Yusuf traveled to Mogadishu, where they fought in battles alongside other U.S. and European fighters who had joined al Shabaab to take control of the city in 2009, prosecutors said.

Ahmed and Yusuf continued to train and fight with al Shabaab, prosecutors said, and Yusuf appeared in a propaganda video filmed in Mogadishu urging people to fight on behalf of the militant group.

The men and a former British citizen, Madhi Hashi, were arrested in August 2012 in Djibouti after illegally crossing the border from Somalia on their way to Yemen to join al Qaeda in the Arabian Peninsula, prosecutors said.

Their lawyers said the men were tortured while in custody in Djibouti over the next several months before being turned over U.S. authorities for prosecution, though their case had no allegations that they intended any direct harm to the United States.

Assistant U.S. Attorney Shreve Ariail said the “unconscionable” treatment they received in Djibouti factored into extending plea deals that capped their prison terms at 15 years.

The men, who before pleading guilty faced 30 years to life in prison, will be deported after they are released from prison.