From left, Attorney General William P. Barr, Deputy Attorney General Rod J. Rosenstein and former attorney general Jeff Sessions share a laugh during Rosenstein’s farewell ceremony at the Justice Department on Thursday. (Chip Somodevilla/Getty Images)

Rod J. Rosenstein, whose two-year tenure as the Justice Department’s No. 2 official was spent in the eye of a public storm surrounding special counsel Robert S. Mueller III’s investigation of President Trump, said farewell Thursday in a ceremony attended by some of the key figures in that probe.

Former White House counsel Donald McGahn was on hand for the ceremony, as was current White House lawyer Emmet Flood. Also in attendance were Trump adviser Kellyanne Conway and former attorney general Jeff Sessions.

While Sessions and the current attorney general, William P. Barr, sat on the stage with Rosenstein, former acting attorney general Matthew G. Whitaker, who also served with Rosenstein, stood in the back of the Justice Department’s Great Hall, largely unnoticed by the hundreds of current and former law enforcement officials there.

Speaker after speaker made explicit reference to or veiled jokes about Rosenstein’s turbulent tenure as deputy attorney general. At times over the last two years, it appeared Rosenstein was on the verge of quitting, or being fired or impeached by fellow Republicans in Congress.

At one point Thursday, a video montage showed images of Rosenstein with his family, and his co-workers, to the theme music of “Band of Brothers,” a miniseries about an Army company that suffered heavy casualties in World War II.

“Things were often a bit not normal,” Sessions said, to laughter from the audience. Rosenstein’s time as deputy attorney general was greatly complicated by Sessions’s recusal in early 2017 from the investigation that emerged from Russia’s interference in the 2016 election, leaving Rosenstein to oversee the politically explosive probe.

“Once started, these things become unstoppable. . . . Rod, you did your duty,” Sessions told his former deputy. “You didn’t ask for it, that’s for sure. The system worked its will, and what more can a public servant do?”

Rosenstein submitted his resignation letter last month, indicating his last day would be Saturday. Trump has nominated Jeffrey Rosen, the deputy secretary of transportation, to succeed him, and a Senate floor vote on that nomination is pending.

For a tenure that was so marked by confrontations and crises, the send-off for Rosenstein was remarkably lighthearted.

Rosenstein aide Ed O’Callaghan gave Rosenstein a prop beard — an inside joke about how O’Callaghan’s beard occasionally garnered headlines — which Rosenstein gamely held up to his chin, winning cheers from the crowd.

At another point, the U.S. attorney for the District of Maryland, Robert K. Hur, a former aide to Rosenstein, made light of a recent report in The Washington Post revealing that during a key meeting with White House officials last year Rosenstein asked not to be fired and seemed to get teary-eyed, according to one person familiar with the exchange.

“I remember a lot of laughter, and I certainly don’t remember any crying,” Hur said. At that, Rosenstein smiled and raised his hands at the crowd.

Hur called Rosenstein’s departure “bittersweet,” noting that his former boss had worked at the Justice Department for decades.

Barr, who on Wednesday faced a biting public rebuke from the House Judiciary Committee, where Democrats voted to hold him in contempt of Congress over his refusal to release the full unredacted version of Mueller’s report, also joked about the situation.

He called Rosenstein up to the podium to ask the crowd “which one of us is capable of the most deadpan expression?”

Rosenstein had been publicly mocked for his rigid demeanor at a news conference alongside Barr the day he publicly discussed the Mueller report. Barr, in turn, kept up a guarded front at a Senate hearing last week in which lawmakers repeatedly castigated him for his handling of the case.

When it came time for Rosenstein to speak, he said the department “stands apart from politics,” adding: ‘The rule of law is not just a talking point, it is an operating principle.”

He alluded at times to the political fights that have raged around Washington and the Justice Department in recent years.

“If kindness and humility are in short supply outside the halls of justice, that’s all the more reason for us to set a good example,” he said. “I leave here confident justice is in good hands; it’s in your hands.”