A 20-year-old Minneapolis man who threatened to "whack" federal law enforcement officials after his friends were charged with terrorist plotting reached a plea agreement Friday that will let him avoid a long prison sentence.

Mahamed Abukar Said pleaded guilty to a gross misdemeanor of "forcibly assaulting, impeding, intimidating and interfering" with a federal law enforcement officer. He faces up to a year in prison and a fine of up to $100,000.

The compromise was struck Friday in federal court in Minneapolis, even as attorneys continued to wrangle over whether the threats were directed at U.S. Attorney Andy Luger, who has led the prosecution of several Minnesota men charged with plotting to join the Islamic State in Iraq and the Levant.

In a series of tweets posted on April 22, Said wrote: "Ima whack that us attorney general," and "BEST BELIEVE ILL KILL FOR THOSE GUYS IF THE DONE FREE MY BROTHERS."

On Friday, Said admitted that he had sent the tweets out of frustration after five friends were charged with conspiring to support Islamic extremists fighting in Syria, but insisted that the threats were aimed at U.S. Attorney General Loretta Lynch.

"I was frustrated and trying to get my anger out, and it was not the smartest way to do it," he told U.S. District Judge Lawrence Piersol of South Dakota. Piersol took the case after defense attorneys objected to another judge because of possible conflicts of interest.

After listening to Said's testimony, Piersol said his admission was made in good faith, but added that "there's question as to who the threats were directed at."

But Said's attorney, Christopher Madel said by phone Friday: "There has never been any threat by my client against Andy Luger and he didn't plead to that either." He pointed to a post-arrest interview with FBI agents in which his client repeatedly referred to the target of his threats as "she."

Prosecutors disagreed, pointing out that Eric Holder, not Lynch, was U.S. attorney general at the time of Said's arrest. Furthermore, they argued in the agreement that Said apologized to the "United States Attorney and the other prosecutors."

U.S. Attorney John W. Vaudreuil of the Western District of Wisconsin, whose office prosecuted the case, said that with Said's guilty plea, the point is moot.

Piersol said he would consider releasing Said to a halfway house pending sentencing, over government objections that Said, who has amassed eight failures to appear in court, remains a flight risk.

The 2013 Como Park High School graduate told the judge he was taking classes at St. Paul Technical College before his arrest, and that he intended to earn a degree someday and study law.

"He's an extremely intelligent young man," Madel said, "that's done some extremely dumb things."

Sentencing is Nov. 23.