WASHINGTON — Longtime Republican campaign adviser Roger Stone, a friend of President Donald Trump's, was sentenced to three years, four months in federal prison Thursday for obstructing a congressional investigation of Russia's 2016 presidential election meddling.

"He was not prosecuted, as some have complained, for standing up for the president. He was prosecuted for covering up for the president," U.S. District Judge Amy Berman Jackson said before she handed down her sentence of 40 months, a $20,000 fine, two years of probation and 250 hours of community service.

Trump has called Stone's prosecution a "disgrace," but Jackson disagreed. "There was nothing unfair, phony or disgraceful about the investigation or the prosecution," she said.

"At his core, Mr. Stone is an insecure person who craves and recklessly pursues attention. Nothing about this case was a joke. It wasn't funny," the judge said.

Stone showed no emotion while the sentence was read, almost appearing bored. He stared with his hands in his pockets and continually rocked on his heels, but he smiled outside the Washington courthouse as he left.

Stone will not have to report to prison until the judge acts on a defense motion for a new trial based on a claim of juror bias.

Asked by Jackson whether he had any statement to make before she handed down her sentence, Stone declined.

Download the NBC News app for breaking news and politics

Stone's sentence would likely end the career of one of the most controversial and colorful political operatives in American history — a self-described "agent provocateur" who spent a career in the shadows of Republican politics before helping to engineer Trump's election. As depicted in the Netflix documentary "Get Me Roger Stone," he saw Trump's potential as a presidential candidate earlier than most.

Stone's attorneys argued that his history in politics, his declining health at age 67 and the low likelihood that he would ever commit another crime called for probation or, at most, home confinement. Federal prosecutors at first recommended a sentence of seven to nine years, but Attorney General William Barr directed Justice Department lawyers to submit a new court filing suggesting that three to four years would be more appropriate.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

In court, however, prosecutor John Crabb, who'd signed the memo asking for a lighter sentence, advocated for the higher sentencing guidelines in the original recommendation. He also apologized to the judge for any confusion caused by the dueling memos.

Crabb said the confusion was not caused by the original trial team, which, he said, had authorization from the U.S. attorney for Washington to file the original sentencing memo. He said the issue was miscommunication between Barr and the U.S. attorney's office in Washington.

"DOJ and the U.S. attorney's office is committed to enforcing the law without fear, favor or political influence," Crabb said.

Trump has lambasted the original prosecutors for unfairly targeting Stone, calling their conduct "disgusting."

Jackson defended the four, who resigned from the case after their sentencing recommendation was overridden.

"Any suggestion that the prosecutors in this case did anything untoward or unethical is incorrect," Jackson said. While she disagreed with its recommended sentence, Jackson said "the government's initial memorandum was thorough, well-researched and supported" by the record.

Trump said Tuesday that Stone "was not involved in our campaign at all," but in August 2015, when he was a candidate, Trump said "I terminated Roger Stone" as a campaign adviser, calling him a publicity seeker. But Stone remained in close contact with the campaign and purported to have an inside track on what WikiLeaks was planning.

The FBI arrested Stone in January 2019 on charges that he misled the Republican-led House Intelligence Committee in 2017 about his efforts to learn of plans by WikiLeaks to release emails hacked from the Democratic Party and Hillary Clinton's presidential campaign. A federal jury in November found Stone guilty of lying to Congress by falsely claiming that he never asked anyone to contact WikiLeaks founder Julian Assange about the emails and that he never spoke to anyone in the Trump campaign about the efforts. Prosecutors said Stone asked a radio talk show host, Randy Credico, to contact Assange and pass messages back and forth.

Former Trump advisers Steve Bannon and Rick Gates testified that Stone was keeping the campaign apprised of his WikiLeaks efforts, and phone records showed that Stone talked to Trump shortly after the Democratic National Committee announced that it had been hacked.

Stone was also accused of urging Credico to lie to Congress about those contacts by emulating a character from "The Godfather: Part II." In the movie, Frank Pentangeli is called to testify before a congressional committee investigating organized crime and is expected to implicate Michael Corleone. But when Corleone enters the hearing room along with Pentangeli's brother, he claims to know nothing about the mob boss.

Stone was never charged with doing anything illegal during the campaign. Instead, the charges were based on his efforts to cover up what he did and to intimidate Credico into doing the same.

While awaiting trial, Stone repeatedly violated the judge's order not to make public statements about the case. Shortly after he was charged, he posted a photo of the judge on social media with what appeared to be the crosshairs of a gun sight next to her head.

The details of the defense motion for a new trial have not been disclosed, but Stone's supporters have said it is based on comments made by the jury forewoman, Tomeka Hart. When the four career prosecutors took themselves off the case, she said on social media: "It pains me to see the DOJ now interfere with the hard work of the prosecutors."

Hart ran for Congress in Tennessee as a Democrat in 2012, a fact she disclosed during jury selection. Asked by Jackson whether she could fairly evaluate the evidence, she said yes, and Stone's attorneys did not seek to have her removed from the jury pool. But Stone's supporters said she posted comments critical of Trump before jurors were summoned for the selection process.

Trump tweeted last week: "Now it looks like the fore person in the jury, in the Roger Stone case, had significant bias." At the sentencing, the judge said the jurors "served with integrity."

Stone's friend Kristin Davis, a former madam who ran for governor of New York in 2013, told NBC News in a text message: "It's rather odd to me to pronounce sentence before we have ascertained the integrity of the trial." She also claimed that there had been "serious undisputed juror misconduct here," apparently referring to Hart's political views.

"It falls on President Trump to use the power of a pardon as the final means of checks and balances to right this horrible wrong," she said.

Trump said Tuesday that he hadn't thought about pardoning Stone. Ahead of the sentencing Thursday, however, he retweeted video of Fox News host Tucker Carlson calling for him to pardon Stone.

After the sentencing, Rep. Adam Schiff, D-Calif., tweeted, "It should go without saying, but to pardon Stone when his crimes were committed to protect Trump would be a breathtaking act of corruption."

For more than four decades, Stone was a political consultant known for aggressively pursuing and using opposition research. He once co-owned a lobbying firm with Paul Manafort, the former Trump campaign chairman who is serving a 7½-year prison sentence for financial crimes stemming from his lobbying work on behalf of the Ukrainian government.

As the sentencing was underway Thursday, Trump questioned on Twitter why Stone would get prison time while also questioning why Clinton and former acting FBI Director Andrew McCabe would walk free.