CHICAGO – A judge raised the specter of the Boston Marathon on Thursday as he sentenced a young Lebanese immigrant 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.

Everyone at Sami Samir Hassoun’s sentencing in a crowded courtroom in Chicago could not help but think of the bombs that went off a month ago concealed in backpacks on the East Coast, killing three people and wounding hundreds more, U.S. District Judge Robert Gettleman said.

“Let’s give the elephant in the room a name: It’s called the Boston Marathon,” he said. “What would have happened had (Hassoun’s) bomb been real would have made Boston look like a minor incident.”

Earlier, prosecutor Joel Hammerman held up the ominous-looking but harmless device fashioned from a paint can that Hassoun put in a trash bin near Wrigley Field, placing it in front of the judge. Hassoun was told by undercover FBI agents, the prosecutor said, that it would destroy half the city block and kill dozens of people.

Minutes before the sentence was announced, 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 asked the judge if he could address his family and friends, and then turned to look at them on a nearby bench.

“I am sorry for the actions that I made and the shame I brought on you,” Hassoun said, struggling to keep his composure. “I promise I will become a better person … and make it up to you.”

His mother sobbed aloud and when Hassoun finished, she said to her son, “I love you!”

Gettleman said he accepted the defense depiction of Hassoun as a uniquely gullible youth — though the judge said that was no excuse for Hassoun’s crime.

During the hearing, prosecutors played secret video recordings of Hassoun during the sting in which he talks about killing people. He explains that one reason to stage the attack along bar-strewn Clark Street is that late-night revelers will be so drunk they wouldn’t notice him dropping a bomb into the trash bin.

As part of an agreement 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.