James B. Comey, the F.B.I. director, keeps a document from the bureau’s archives on his desk, like a memento mori. It’s the application that his predecessor, J. Edgar Hoover, made to the Justice Department to wiretap the Reverend Dr. Martin Luther King, Jr., together with the approval granted by the Attorney General, Robert F. Kennedy. It is a single page. “The entire application is five sentences long, it is without fact or substance, and it is predicated on the naked assertion that ‘there is Communist influence in the racial situation,’ ” Comey told an audience at Georgetown University in February of 2015. He explained that these days, as the bureau’s director, he requires F.B.I. agents and analysts in training to “study the F.B.I.’s interaction” with King and pay a visit to the Martin Luther King, Jr., Memorial in Washington, D.C. “The reason I do those things is to insure that we remember our mistakes and that we learn from them,” he said.

Comey might do well to keep a different document from the archive on his desk: a page from the six-hundred-page file that the bureau kept on Reinhold Niebuhr, the theologian and public intellectual, who died in 1971. Like the King document, it would serve as a reminder of the conflicts—the contradictions—that come with public service.

Last week, a strong piece of Internet sleuthing by Ashley Feinberg, at Gizmodo, asserted that “Reinhold Niebuhr” is the Twitter identity for an account Comey set up recently. Niebuhr was a topic of the senior thesis that Comey wrote as a student at the College of William and Mary, in 1982: “The Christian in Politics,” a study of the role of religious beliefs in public service. To judge from Comey’s Georgetown address—a sensitive statement about the “hard truths” of race and law enforcement and the role of human weakness, or bias—Niebuhr is a model for Comey (a Methodist who has taught Sunday school) in his role as F.B.I. director. And Niebuhr’s characteristic outlook, known as “Christian realism”—which sets the need for courageous moral action against the fact of human weakness—is an apt frame of reference for the political hot spot that Comey finds himself in.

“The ‘irony,’ to use a Niebuhrism, of the situation is exquisite,” the filmmaker Martin Doblmeier told me, referring to Niebuhr’s 1952 book, “The Irony of American History.” The F.B.I. chief has an F.B.I. target as his hero; the head of U.S. domestic intelligence can’t keep his Twitter account secret.

Doblmeier is the director of “An American Conscience: The Reinhold Niebuhr Story,” a documentary released in March. The film’s opening sequence sets out the now familiar premise that Niebuhr has become a thinker with fresh significance to people who are concerned with the place of ideas and conscience in public life. There’s a photomontage of Barack Obama, who called Niebuhr “one of my favorite philosophers” while a senator and cited his “compelling idea that there’s serious evil in the world.” David Brooks, who has addressed Niebuhr’s thought in many Times columns and in his book “The Road to Character,” praises Niebuhr’s “audacity” and his influence on both sides of the congressional aisle. Jimmy Carter testifies to the image of Niebuhr as a “constant presence” during his Presidency.

Niebuhr’s thought is complex and resists summary; nevertheless, his central ideas are naturally attractive to figures in public life because he persuasively depicted the conflicts of public figures over “right” action as episodes in a grand, Biblically inflected drama of human nature and destiny.

For Niebuhr, simple schemes of good and evil—such as those of the Cold War—are to be resisted, but certain conflicts really do involve questions of good and evil. In some situations, taking moral action involves committing acts that would be distasteful in other situations: if you are going to defend a free society against a warlike aggressor, you are likely going to have to kill some people. Most human actions have unforeseen consequences, and these often turn out to be more significant than the consequences the people who took those actions had in mind. Americans, raised in a young country, lack a sense of history and are estranged from the Biblical roots of American ideals. As a result, our leaders overestimate their personal virtue, the merits of the American project, and the ability of our institutions (such as the military) to carry out their objectives, and this leads them to pride and shortsightedness. All political acts take place under the judgment of history, which reveals “the limits of all human striving” and the futility, even the folly, of most human undertakings, especially of politics.

Niebuhr is also appealing to public figures because he put his ideas to the test in public life, although doing so prompted accusations of inconsistency, and the suspicion—familiar to James Comey—that he was lending his support to the wrong side. In the documentary, the ethicist Ronald H. Stone (who was Niebuhr’s last teaching assistant at Union Theological Seminary, in New York City) explains that the basis for the F.B.I.’s investigation was J. Edgar Hoover’s view that “anybody who belonged to so many left-wing organizations had to be a Communist.” And yet Niebuhr had long since renounced his early pacifism, and, with Hitler’s rise to power, he had urged the U.S. to join the Allies in military action against Nazi Germany, even though taking those positions meant breaking ranks with dozens of close friends on the left.

After the war, Niebuhr joined his friend Arthur Schlesinger, the historian, on a committee convened to advise the State Department on the moral dimension of America’s role in the emerging world order. During John F. Kennedy’s campaign for President, in 1960, Niebuhr introduced Kennedy at a Liberal Party dinner. And yet Niebuhr faulted Kennedy, a Roman Catholic known for his womanizing, for the lack of “moral fiber” and for the “thinness” of his religion. Niebuhr also pointedly opposed the Ku Klux Klan as a young pastor in Detroit, and his book “Moral Man and Immoral Society,” from 1932, was a profound influence on Martin Luther King, Jr., (who eventually, in his “Letter from a Birmingham Jail,” attributed to Niebuhr the insight that “groups tend to be more immoral than individuals”). And yet when Niebuhr, after Brown v. Board of Education, was asked to sign a petition appealing to President Eisenhower to intervene on behalf of black students against a white Southern society still clinging to segregation, he declined to do so out of a conviction that social change could not be imposed abruptly from without. Niebuhr was a vociferous critic of the Vietnam War when, under Lyndon Johnson, he was awarded the Presidential Medal of Freedom. As Doblmeier ruefully notes, Niebuhr was still on the F.B.I.’s watch list.

To see Niebuhr’s story with Comey in mind is to gain a deeper appreciation of the hard choices Comey has faced—and the perils of going it alone, as he has seemed to do at several points. In the final months of the 2016 Presidential campaign, Comey faced two moral dilemmas of profound import. In the first, as Newsweek has reported, by last July the agency held evidence that Russia sought to interfere in the election—and presumably to swing the result in favor of Donald Trump rather than Hillary Clinton. Comey, seeing clear wrongdoing, was eager to take action. During a meeting in the White House Situation Room with top Administration officials, Comey proposed to set out the intelligence in an opinion piece for, say, the Times. “He had a draft of it or an outline. He held up a piece of paper . . .” a source told Newsweek, “and said, ‘I want to go forward. What do people think of this?’ ” The Administration rejected the idea, on the grounds that there should be a “coordinated message,” not a piece of journalism by a single official, and also possibly out of a disinclination to be seen as interfering in the campaign.