What would have been Minnesota's first ISIL-related federal trial turned into a study in remorse Tuesday morning, when a young Minneapolis man accepted a plea agreement, swapping his orange jail garb for a striped dress shirt and embracing a crush of loved ones outside the courthouse in Minneapolis.

Khaalid Abdulkadir, 19, was charged with tweeting death threats against a federal judge and agents late last year and faced up to 15 years in prison. Instead, he pleaded guilty to a misdemeanor charge of attempting to intimidate a federal judge and federal law enforcement officers and received three years of probation with conditions that include GPS monitoring.

"I didn't expect it to get this big," Abdulkadir told a group of reporters after his release outside the U.S. Federal Courthouse. "I didn't expect the [indictment] to get dropped either, but with the blessing of God it got dropped."

Abdulkadir and his lawyers had shown up at the courthouse late Monday afternoon expecting a pretrial conference only to find that prosecutors were offering a plea deal.

That set off an intense round of talks among Abdulkadir, his attorneys, parents and Somali-American community leaders.

Chris Madel, one of Abdulkadir's attorneys, told U.S. District Judge Karen Schreier of South Dakota on Tuesday that he assured Abdulkadir that he thought he could win an acquittal.

"Doesn't matter: I did it," Abdulkadir replied.

On Tuesday morning, as the plea hearing unfolded, Abdulkadir's father, Adam Aded, addressed Schreier before she imposed the sentence, asking her to release him to their supervision.

"I think we [got] justice here," Aded said. "I don't like what he did, but we ask that he be released and we will always watch him."

Assistant U.S. Attorney Charles Kovats pointed out the seriousness of the conduct involved, saying, "These threats undermine the rule of law, and the government takes them seriously." But he added that his office thought the plea agreement balanced the threats with the defendant's young age.

"By his own admission in court today, Mr. Abdulkadir threatened to kill a federal judge and law enforcement officers," said U.S. Attorney Andrew Luger. "The three years of probation he will begin serving today is a strong reminder that threatening federal officials with violence is not a legitimate means of voicing dissent, but will be prosecuted forcefully by my office."

Before imposing Abdulkadir's sentence, Schreier agreed on the gravity of the behavior and said his age — 19 at the time — played a factor. Noting that Abdulkadir had quickly erased the tweets, Schreier said she believed he realized he had erred.

"I've looked at your background," Schreier said. "You should be proud of what you've accomplished other than this event. Be very careful on who you're friends with."

A rare case

Abdulkadir would have been the first Twin Cities defendant in a case related to the Islamic State in Iraq and the Levant to stand trial. His also appeared to be one of the rare online-threat cases on track to go to trial anywhere in the country.

Until Tuesday, Abdulkadir had been held without bail in Sherburne County jail since agents stormed his south Minneapolis home and arrested him in December.

Hours after Abdirizak Warsame was arrested and charged on Dec. 9 with conspiracy to provide material support to a foreign terror group, Abdulkadir tweeted, "More brother get locked up the cops body they will find on the floor body's dropping fast #kill them FBI and [expletive] as judge." Another tweet read: "[Expletive] them F.B.I. I'm kill them FEDS for take my brothers."

A government informant captured screen shots of the tweets before they were taken down and sent them to an FBI agent.

After the hearing adjourned on Tuesday, Madel said he had planned to ask why authorities waited more than 36 hours after Abdulkadir's tweets before arresting him.

"Our contention at trial was going to be that the FBI didn't think this guy was going to be a serious threat," Madel said.

The government's 10-month investigation of terrorist recruitment in Minnesota has resulted in charges against a dozen young men. Four have pleaded guilty to conspiracy to provide support to a foreign terrorist organization, and five are scheduled to stand trial in May.

Abdulkadir was one of two charged with using Twitter to make threats against federal law-enforcement officials.

Conditions of Abdulkadir's sentence also include regular drug testing, random examination of his computer activity and mental health counseling. In addition, he is forbidden from accessing any material that includes "extremist or terrorist views." He will also be unable to apply for a passport.

Twitter: @smontemayor