Roger Stone, a staunch ally of President Donald Trump, was sentenced to 40 months in prison Thursday afternoon for witness tampering and lying to Congress.

Prosecutors initially asked for seven to nine years in prison — but Attorney General William Barr retracted that recommendation hours after Trump criticized it on Twitter for being too harsh.

Instead, U.S. District Judge Amy Berman Jackson took Barr’s recommendation of 40 months in sentencing the president’s longtime friend. She also fined Stone $20,000 and continued a gag order, prohibiting Stone from speaking about the case.

Jackson said during the hearing Stone’s use of social media to stoke public sentiment against the prosecution and the court was intended to reach a wide audience, including using a photo of Jackson with crosshairs superimposed.

“This is intolerable to the administration of justice,” Jackson said.

The U.S. Attorney General said Thursday that President Donald Trump’s tweets “make it impossible for me to do my job.” William Barr was referring to this week's debacle over the Department of Justice seeking a lighter prison sentence for Trump ally Roger Stone. The four prosecutors in the case recommended that Stone serve between 7 to 9 years in prison. But the recommendation was revised after a tweet from the president criticized it as “very horrible and unfair." That's when the four prosecutors resig

“Why are you the one who is standing here today?” Jackson asked federal prosecutor John Crabb, who took over the case after the original trial team quit.

Stone exited the courthouse shortly 1:00 p.m., and did not speak to supporters. A small but loud crowd of supporters and opponents, with many shouts of “Lock him up!”

Outside the courthouse, a small crowd gathered. Two people held a large banner featuring a sketch of Stone and #PardonRogerStone emblazoned underneath. Next to it was a large multimedia figure of a rat constructed to look like Trump, with his distinctive red tie and hair.

Stone’s lawyers had asked for a sentence of probation, citing his age of 67 years, his health and his lack of criminal history.

Stone was convicted in November on all seven counts of an indictment that accused him of lying to Congress, tampering with a witness and obstructing the House investigation into whether the Trump campaign coordinated with Russia to tip the 2016 election.

Jackson took a firm stance toward Stone, faulting him for the actions that led to the charges.

“Mr. Stone lied,” Jackson said, adding Stone injected himself “smack” into a political controversy and was not “persecuted,” as his attorneys argued.

The action in federal court comes amid Trump’s unrelenting defense of his longtime confidant that has led to a mini-revolt inside the Justice Department and allegations the president has interfered in the case.

The president himself was again taking to social media while Stone’s case was being heard Thursday morning.

» MORE: Who is Roger Stone, what links him to Trump?

Four lawyers who prosecuted Stone quit the case last week after the Justice Department said it would take the extraordinary step of lowering the amount of prison time it would seek for Trump’s longtime confidant.

The U.S. Attorney General said Thursday that President Donald Trump’s tweets “make it impossible for me to do my job.” William Barr was referring to this week's debacle over the Department of Justice seeking a lighter prison sentence for Trump ally Roger Stone. The four prosecutors in the case recommended that Stone serve between 7 to 9 years in prison. But the recommendation was revised after a tweet from the president criticized it as “very horrible and unfair." That's when the four prosecutors resig

The decision by the Justice Department came hours after Trump complained that the recommended sentence for Stone was “very horrible and unfair.” The Justice Department said the sentencing recommendation was made before Trump’s tweet  and prosecutors had not spoken to the White House about it.

The four attorneys, including two who were early members of special counsel Robert Mueller’s Russia team, had made up the Justice Department’s trial team and had signed onto a court filing that recommended up to nine years in prison for Stone.

»Who are the 4 prosecutors who quit the Roger Stone case?

The department’s decision to back off the sentencing recommendation raised questions about political interference and whether Trump’s views hold unusual sway over the Justice Department, which is meant to operate independently of the White House in criminal investigations and prosecutions.

Senator Chuck Schumer is calling for an investigation into the U.S. Department of Justice. The DOJ sought a lighter prison sentence than prosecutors originally asked for against Roger Stone, a longtime ally of President Donald Trump. Stone was convicted in November of obstruction and witness tampering as a result of the Russia investigation by special counsel Robert Mueller. The four prosecutors in the case recommended that Stone serve between 7 to 9 years in prison. The recommendation was revised after

Barr has been a steady ally of Trump’s, clearing the president of obstruction of justice even when special counsel Robert Mueller had pointedly declined to do so and declaring that the FBI’s Russia investigation — which resulted in charges against Stone — had been based on a “bogus narrative.”

Stone was the sixth Trump aide or adviser to be convicted of charges brought as part of special counsel Robert Mueller’s Russia investigation.

Any jail sentence seems likely to draw a public rebuke from Trump, who maintains Stone’s entire case is just an aspect of the ongoing “witch hunt” against him and his allies by bitter Democrats and the “deep state” inside the FBI and the Justice Department.

Roger Stone, an associate of President Donald Trump, has been arrested in Florida.

Given Trump’s recent clemency spree that saw him commute the sentence of former Illinois Gov. Rod Blagojevich, as well as nearly a dozen others, there has been speculation that Trump could eventually pardon Stone.

Stone, 67, has denied wrongdoing and consistently criticized the case against him as politically motivated. He did not take the stand during his trial and his lawyers did not call any witnesses in his defense.

The Associated Press contributed to this report.