A young Lebanese immigrant was sentenced Thursday to 23 years in prison for placing a backpack he believed contained a powerful bomb along a bustling city street near the Chicago Cubs’ baseball stadium.

Sami Samir Hassoun’s sentencing in federal court in Chicago came little more than a month after bombs concealed in backpacks exploded at the Boston Marathon, killing three people and wounding hundreds more.

In imposing the sentence, the judge invoked the specter of the Boston Marathon, saying had Hassoun’s bomb been real, it would have made Boston look like a minor incident by comparison.

Minutes before, Hassoun, a 25-year-old one-time Chicago baker and candy-store worker, apologized for what he’d done in a five-minute statement. Crying, he also turned to look at his mother and several friends on a nearby bench and told them he was sorry “for the shame I brought on you.”

His mother sobbed aloud and said back to her son: “I love you.”

The defense has depicted Hassoun as a uniquely gullible youth sucked into the 2010 terrorism sting during an alcohol-addled stretch of his life by an informant eager to please his FBI handlers.

But prosecutors say he showed enthusiasm and initiative, including when he decided to drop the device given to him by undercover agents into a trash bin near Wrigley Field and a bar packed with late-night revelers.

As part of a plea deal with the government, Hassoun pleaded guilty last year to two explosives counts. In return, he faced a sentencing range of 20 to 30 years, rather than a maximum term of life in prison.

At Thursday’s hearing, government attorneys displayed the fake bomb undercover agents gave Hassoun on a September weekend in 2010.

They also played a surveillance video of Hassoun dropping the device into a trash bin near the stadium shortly after receiving it. FBI agents arrested him moments later.

Before Thursday’s sentencing, Hassoun apologized in a seven-page letter to his sentencing judge, Robert Gettleman. He also insisted he’s worked hard at becoming a better person.

The Beirut-born Hassoun blamed his actions in part on childhood trauma living in Abidjan, Ivory Coast. During civil strife there, Hassoun, then 11, witnessed machete killings from an apartment balcony, he wrote.

Fleeing that African nation, he said he left everything he knew behind, even his beloved collection of “ninja turtles, matchbox cars (and) Japanese cartoons.” His family emigrated from Lebanon to the U.S. in 2008.

To dampen his lingering emotional pain, he wrote that he drank alcohol “all day, every day” for months before the would-be stadium attack in 2010. He favored whole bottles of Johnnie Walker Black, he wrote.

In a recent presentencing filing, the defense suggested investigators may have entrapped Hassoun, arguing the paid informant egged Hassoun on to acquiesce to ever-more ominous-sounding plots.

Prone to boasting and eager to impress, Hassoun even made what the defense describes as absurd claims he could make a gun out of two pieces of wood and a spring, and a bomb out of baking soda.

But so inept was Hassoun, he bought a backpack, walkie-talkies and some batteries agents asked him to buy, and the FBI then incorporated it into a dud bomb fashioned at its lab in Quantico, Va., defense filings say.

But far from being led on, prosecutors say Hassoun himself concluded that maximum damage could be inflicted by a blast next to the popular Sluggers World Class Sports Bar, just steps from Wrigley Field.

“He selected the day and time at which to strike — midnight on a Saturday night — to maximize the number of prospective casualties,” prosecutors said. He walked away expecting “chaos and carnage.”