(Sarah Parnass/The Washington Post)

For his performance of a lifetime, James B. Comey, finally free to speak his mind about the president who sacked him, decided to play two roles at once: The prototypical G-man, always on the straight and narrow, dedicated only to truth and justice, and the aggrieved victim of an undisciplined, line-crossing president.

In both roles, the play ends with Comey, the deposed FBI director, in a new and uncomfortable place — as the whistleblower, warning the nation about a president who schemes, lies and seeks to corrupt public servants under the guise of loyalty.

For more than 2 ½ hours before the Senate Intelligence Committee on Thursday, Comey, stern and unsmiling, rocked back and forth between stirring paeans to the men and women of the bureau (“Thank you for standing watch”) and a righteous role as the one person with sufficient standing and spine to call out President Trump (“I was honestly concerned that he might lie about the nature of our meeting”).

Comey was alternately searingly blunt and tepidly cautious. He was folksy, entertaining the senators with the story of how he had to cancel a dinner date with his wife to accept a last-minute invitation to dine with the president. And he was melodramatic, wrapping his account of his encounters with the president in rhetoric about duty. He even tossed in a dark reference to a classic play about King Henry II and the “meddlesome priest” he wanted removed from this mortal coil.

Comey was a little bit Jimmy Stewart, sprinkling his answers with aw-shucks modesty, even exclaiming “Lordy!” at one point. And he was a little bit John Dean, not quite declaring a cancer on the presidency but pronouncing himself very much “shocked and troubled” by what he perceived as Trump’s repeated efforts to get him to ease off the FBI’s investigation into Russia’s role in the 2016 election.

(Bastien Inzaurralde/The Washington Post)

When Sen. Dianne Feinstein (D-Calif.) asked why Comey hadn’t stopped Trump cold and refused to listen to any entreaties to back off the investigation, Comey said, “Maybe if I were stronger, I would have.”

As in the legendary “Saturday Night Live” bit about the miracle product Shimmer, which turns out to be both a floor wax and a dessert topping, Comey decided to play both roles.

“This was an unusually explicit example of someone in public life walking a tightrope between roles,” said Derek Goldman, a theater director and founder of the Laboratory for Global Performance and Politics at Georgetown University. “Comey was trying to get across that ‘I’m trustworthy and I acted with integrity, on behalf of the greater good.’ That requires both his ‘aw, shucks’ dignity and a capacity to speak truth to power, to blow the whistle.”

Comey undertook that tightrope act without a net — although with plenty of preparation. He delivered his opening statement without notes. He was pointedly more forthcoming in a public session than the director of national intelligence, Daniel Coats, and the National Security Agency chief, Adm. Mike Rogers, had been before the same committee the previous day.

Comey delivered his central message with rare bluntness, saying that the White House “chose to defame” him. As a man who regularly refers to how political events sour his stomach, Comey used words that had to give the president indigestion. Here was the nation’s former chief law enforcement officer saying five times that Trump does not tell the truth, accusing the president of “lies, plain and simple.”

Yet for every accusation he leveled, Comey again and again stepped back, serving up large doses of modesty: “Again, I could be wrong. . . . Again, it’s my impression . . . .”

He balanced all that hemming and hawing about how he’s just a public servant with words that could end up atop a list of particulars in any legal case against Trump: “I mean, this is the president of the United States, with me alone, saying ‘I hope . . . you can let this go. . . . I took it as, ‘This is what he wants me to do.’ ”

(Kate Woodsome,Monica Akhtar,Dana Milbank/The Washington Post)

Comey repeatedly asserted that he interpreted the president’s words to him to mean that he should back off the investigation into connections between Russia and the Trump campaign. Yet Comey also again and again conceded that he had not pushed back directly against the president during their meetings.

“I was a bit stunned and didn’t have the presence of mind,” Comey told Sen. Marco Rubio (R-Fla.). The FBI director was not, he said, “Captain Courageous.”

Was that a frank admission of how even the chief of the FBI could be cowed by the awesomeness of the Oval Office, or was it a calculated attempt to present himself to the committee and the American people as a flawed but honorable servant, a martyr who has sacrificed his career-pinnacle job in service of telling the truth?

“Dramatically, he’s a complex character,” said Ifa Bayeza, a playwright and director now working on a trilogy about Emmett Till, the black teen who was lynched in Mississippi in 1955. “He tried to thread the needle and play both the consummate FBI guy and the ‘lordy, gosh, gee’ character.” Bayeza noted that “very tall people” — Comey is 6-foot-8 — “develop ways to go through life without seeming intimidating.”

Comey seemed aware that he had some persuading to do. A Washington Post-ABC News poll earlier this week found that 36 percent of Americans said they had a good or great level of trust in what Comey said about Russia and the election, while 55 percent said they trusted him little or not at all. The skepticism was spread across party lines, an artifact of the anger that swept the nation last year after Comey’s surprise announcements that the investigation into Hillary Clinton’s misuse of email servers was on again and then off again.

Comey’s eagerness to prove his honesty and goodwill came through in his folksy manner and old-fashioned language. “We’ve suffered an assault on our baseline of public decorum,” Bayeza said. “Comey is responding to the crassness of language that has invaded the public space.”

Comey also sought to persuade with an unusual dose of frankness. He broke a Washington code by admitting that he was the original source behind news stories about a memo he had written detailing his conversations with Trump. “I needed to get that out into the public square,” he told the committee, describing how he’d shared the memo with a friend who is a law professor at Columbia.

And as if to prove that he was constitutionally incapable of playing favorites, Comey focused his criticism not only on Trump but also on a list of others whose behavior he had found lacking. The former attorney general, Loretta E. Lynch, left him feeling “queasy.” Comey said he informed the new deputy attorney general, Rod J. Rosenstein, about Trump’s line-crossing, but nothing seemed to happen. And Comey called out a New York Times article as inaccurate. Lynch, Rosenstein and the Times were not amused.

Comey’s purpose in all this seemed to be some blend of setting the record straight, pushing back against the president’s norm-shattering ways, and, perhaps, helping to build a case against Trump.

Asked directly whether the president’s actions constituted obstruction of justice, Comey demurred. But later, he explained that he had kept detailed notes of his moments with Trump because “if I write it in such a way that I don’t include anything that would trigger a classification, that’ll make it easier for us to discuss, within the FBI and the government, and to hold on to it in a way that makes it accessible to us.”

Comey was, he made clear, conducting his own investigation, and now, even though he’s no longer chief of the FBI, he’s pushing it forward. He wrote an elegant summation of his case and put it out the day before his testimony, buying a second news cycle of national attention and setting the terms for his appearance in the Senate. Then, in a performance that won praise from Democrats and Republicans alike, he added new fuel to an investigation that has nearly paralyzed the president who promised that “now arrives the hour of action.”

A quarter century ago, the future president said of his relentless focus on personal branding that “the show is Trump, and it is sold-out performances everywhere.” On Thursday, an unscripted character added himself to the show.