WASHINGTON — In a surprise development, a federal judge agreed during a highly-anticipated Tuesday hearing to delay the sentencing of former Trump national security adviser Michael Flynn.

All sides seemed prepared to press forward with sentencing until just before 1 p.m. ET. But after U.S. District Judge Emmet G. Sullivan raked Flynn over the coals for lying to the FBI about his contacts with Russian officials—even hinting that he might impose a prison sentence—Flynn’s lawyers reversed course.

To allow Flynn to “eke out the last modicum” of his cooperation with special counsel Robert Mueller and receive the most favorable sentence possible, Flynn attorney Robert Kelner asked that the sentencing date be pushed to next year.

Sullivan agreed, postponing the conclusion of Flynn’s involvement in the high-stakes investigation into Russia’s interference in the 2016 presidential election.

The judge had offered warning shots to the former national security adviser, saying that Flynn’s offenses prompted feelings of “disdain” and “disgust.” Both Mueller and Flynn’s team had recommended that the retired general serve no prison time given what the special counsel called his “substantial” cooperation with their probe. But Sullivan made clear that he was dismayed by Flynn’s conduct and that prison was not out of the question.

The reversal on the sentencing was only the final twist in the dramatic hearing. Flynn is the highest-ranking Trump administration official to agree to cooperate with Mueller’s investigation of Russian interference in the 2016 election. He is also at the center of numerous far-right conspiracy theories about Mueller’s investigations.

Sullivan kicked off Tuesday’s proceedings by grilling Flynn about his guilty plea and whether he accepted responsibility for his crimes.

Flynn’s attorneys and supporters have suggested in recent days that he was entrapped into lying to the FBI at a January 2017 interview at the White House, with agents neglecting to encourage Flynn to bring an attorney or inform him that lying to the FBI was a crime. Flynn falsely told FBI agents at that sit-down that he never spoke to Russia’s former ambassador to the U.S. about lifting sanctions against Russia or a pending UN resolution on Israel.

Flynn confirmed Tuesday that he was “aware” that lying to the FBI is a crime.

He added that he was able to review all relevant information before agreeing to the plea deal, and that he had no intention of withdrawing his guilty plea.

Sullivan asserted that it was a “very serious offense” for a senior government official to lie to the FBI “while on the physical premises of the White House.” He also asked Van Grack about the indictment unveiled this week against Flynn’s former business partners for their lobbying effort to discredit a U.S.-based Turkish cleric loathed by Turkey’s government. Noting Flynn’s heavy involvement with the project, Sullivan asked if Flynn could have faced serious criminal liability in that matter as well.

Van Grack confirmed that Flynn’s exposure for prison time would have been great.

Following the recess, Flynn attorney Kelner announced that his client is “prepared” to offer assistance in the Eastern District of Virginia’s case against his two former associates, Ekim Alptekin and Bijan Kian.

The courtroom was packed with reporters and spectators, as well as Flynn’s wife, Lori, and his son, Michael Flynn Jr., who has promoted anti-Mueller conspiracies on social media. Flynn’s mood appeared to sour over the course of the hearing, going from calm and focused to downcast.

Flynn is in a rare position among Trump associates who have agreed to cooperate with Mueller’s investigation. While the President has denigrated other cooperators as “rats” or “weak,” the President has treated Flynn with kid gloves. Hours before the sentencing hearing began, Trump wished Flynn “good luck today in court” and said it would be “interesting to see what he has to say, despite tremendous pressure being put on him.”

Legal experts maintain that Trump’s comments amount to efforts to influence a government witness’ testimony.

Flynn’s public silence since his plea agreement was announced have left it unclear exactly how he is trying to balance his arrangement with Mueller and still-friendly relationship with the President, who could grant him a pardon.

During the 2016 presidential campaign, the retired general offered a full-throated embrace of far-right conspiracies, leading “lock her up” chants for Hillary Clinton and saying it was “rational” to fear Muslims. Trump brought Flynn into the White House as national security adviser, where he served for only two weeks before he was ousted amid outcry about his contacts with Russia.

This post has been updated.