Two men were sent to prison Monday for their key roles in what prosecutors said was a terrorist "pipeline" to send young men to fight in the Somali civil war.

Muhamud Said Omar, 46, a janitor at a Minneapolis mosque, who was convicted in 2012 of aiding foreign terrorism, was sentenced to 20 years in prison. Prosecutors had asked for 50 years.

Kamal Said Hassan, 28, also of Minneapolis, who pleaded guilty in 2009 to aiding terrorism and lying to the FBI, was sentenced to 10 years.

He could have received up to 38 years, but prosecutors cited his extensive cooperation which helped them win other convictions.

The sentences cap a federal investigation lasting more than four years. Authorities sought to shut down a recruiting effort that lured more than 20 young men to Somalia, several of whom died fighting or in suicide bombings.

Seven more individuals will be sentenced by U.S. District Court Judge Michael Davis this week for similar crimes of aiding terrorism in a foreign country; four on Tuesday, and three on Thursday.

In a statement Monday, John Carlin, acting assistant U.S. Attorney General for national security, hailed the "successful prosecutions" of "two individuals who played crucial roles in raising funds and recruiting fighters from the United States to assist Al-Shabab."

Davis made it clear he was unsympathetic to the defense's contention that the two men supported the insurgency in opposition to the 2006 invasion of Somalia by Ethiopian troops.

More than 20 people from the Somali community attended the sentencing. Afterward, Hassan Mohamud, a St. Paul imam, spoke to reporters and stressed that the public was in no way endangered by the local Somali community.

While praising Davis for the extra time he gave the defendants to speak, he also said Davis did not understand the questionable nature of Ethiopia's invasion, an act that was opposed by the local Somali community.

Davis had stressed that as a local judge, he was not about to rule on whether the transitional government, which had invited the Ethiopian troops into the country, was a legitimate regime. The United States had recognized the transitional government, making an attack on either that government or Ethiopian troops a criminal act, according to prosecutors.

The people charged in Minneapolis are accused of supporting Al-Shabab, which fought the Ethiopians and was declared a terrorist group by the State Department in 2008.

Omar's defense attorneys, Andrew Birrell and Jon Hopeman, had argued that Omar "was a pawn, who, because of his mental disabilities became involved in a organization whose evil was far more advanced than he could comprehend."

At the sentencing, Birrell said prosecutors had "not found one shred of evidence" Omar had ever said anything against the U.S. government or picked up a gun against it.

Davis asked Omar if he had any comment, at which point Omar launched into a rambling, largely incomprehensible talk, which lasted about an hour. He said his attorneys had failed him, praised Judge Davis, the U.S. government and American people and declared that he never smoked or drank.

Davis asked if any relative could clarify some of Omar's comments, and a younger brother, Abdullahi Omar, stepped forward to answer some questions from Davis.

Prosecutors considered Omar a ringleader.

Three men who went to Somalia to fight testified that Omar arranged their travel. They said Omar flew to Somalia, went to an Al-Shabab safe house in 2008 and provided cash for rifles. Prosecutors said he helped arrange travel for six more recruits in 2008 even after Shirwa Ahmed, of Minneapolis, blew himself up in a suicide attack in Somalia.

Assistant U.S. Attorney John Docherty said Omar only stopped recruiting because federal authorities stepped in. He said a long sentence was needed to prevent him from resuming his activities.

In court on Monday, federal prosecutors recommended that Hassan serve no more than 10 to 12 years because of "extraordinary cooperation" with federal investigators.

Hassan pleaded guilty Aug. 12, 2009, to two terror-related counts, and testified against Omar in hopes of receiving a shorter sentence.

Hassan had testified that he left Minneapolis for Somalia in 2007. He went to a training camp where he learned to fight and was featured in a promotional video encouraging other Americans to join the fight. "I was a foot soldier," he said. "Mujahedeen."

In 2008, he said, he and other Minnesotans were involved in an ambush of Ethiopian soldiers but that he had not fired a gun. After that, he said he fled Al-Shabab with the help of his family and the FBI.

On Monday, Hassan told Davis he wanted to work and take care of his wife and new child.

"I can do better," he said. "I know what I did is wrong and illegal … I let my family down, I let my country down and I let my community down. … I cannot express to you how sorry I am for everything I did."

Davis, paused for a long moment, then stared down at Hassan and said he had heard "a lot of sorries" but thought Hassan was both "very bright" and "very devious." He said he believed Hassan had lied to authorities when he claimed he did not fire a gun — which Hassan again denied.

Davis also said that while Hassan was being housed in a hotel and supplying information to prosecutors, he was allowed conjugal visits, "bringing a child into the world" who won't have a father because Hassan was going to prison.

However, Davis, in imposing his sentence, echoed prosecutor William Narus, and defense attorney Manny Atwal in citing Hassan's cooperation with the FBI. "It is clear the defendant has given extraordinary, extraordinary cooperation," he said. He was sentenced to 10 years for the two counts of aiding a terrorist organization and eight years for lying to the FBI, both sentences to run concurrently.

Both men have been in jail for several years awaiting sentencing, and it is expected that those years will be deducted from their sentences.

Generally, defendants in federal cases serve 85 percent of their sentences.