A Portland man was sentenced Friday to 30 years in federal prison for leading a crack cocaine trafficking conspiracy, the U.S. Attorney’s Office said.

U.S. District Judge Nancy Torresen cited the criminal record of Hamadi Hassan, 32, and his violent nature in imposing the long sentence at a hearing in federal court in Portland. Hassan pleaded guilty in May.

Hassan has three prior convictions for drug trafficking and violent crimes, Torresen said, and he and co-conspirators often carried guns and large sums of cash with them while they operated between November 2010 and February 2012.

Hassan took orders for crack from customers and co-conspirators and went to Boston to buy the cocaine and bring it back to Portland, authorities said. A co-conspirator, Biniam Tsegai, 28, also of Portland, was sentenced Friday to eight years in federal prison for preparing the crack for sale and distribution in Maine.

Tsegai also pleaded guilty in May. He is believed to be the last known owner of a handgun that allegedly was used by the Tsarnaev brothers after the Boston Marathon bombings in 2013. A Los Angeles Times report said police believe the gun was used by Tamerlan Tsarnaev, later killed in a shootout with police, to kill an MIT police officer during the manhunt for the two brothers.

Torresen said Hassan and Tsegai hid crack around Portland in milk containers or cigarette cartons. In May 2011, police found more than 20 grams of crack in a cigarette box in a play area of a local day care facility, she said.

At the sentencing hearing, federal prosecutors said Hassan threw one woman to the ground and stomped on her, breaking her ribs, over an unpaid drug debt. A second woman, they said, was choked and Hassan threatened to kill her if she cooperated with authorities. A third woman, according to prosecutors, was forced to sell drugs from her hospital bed after she was admitted.