WASHINGTON ― You have to be extremely political here in the nation’s capital if you want to acquire a reputation for being nonpolitical.

James Comey, as shrewd and politically attuned a player as this city has seen, had accomplished that feat ― until it all fell apart on Friday.

Seeking to protect his reputation for impartiality, the FBI director instead revealed his obsession with politics: the politics of his own image.

He sent Congress a vaguely worded letter about how the bureau had come across new information that “appeared to be pertinent” to the “completed” investigation of former Secretary of State Hillary Clinton’s emails.

It soon became clear what he was talking about: emails, the contents of which the FBI hadn’t seen, on the laptop of Anthony Weiner, the estranged husband of Clinton aide Huma Abedin.

The decision for a new investigation, he said in an internal letter that was quickly leaking, was an agonizing one ― though not nearly as agonizing as it was to the presidential campaign of the woman he had put back in his sights.

The Clinton camp is outraged; Donald Trump’s supporters suddenly have renewed faith in at least one part of the system they claim is “rigged” against them. And some people are shocked, shocked that Comey would ever make such a move.

They shouldn’t be.

From the beginning, Comey has had his eye on mastering the intersection of law, politics and power in Washington and elsewhere. He is a very tall man (6-foot-8) who began as a younger man with something to prove and a burning desire to prove it.

Mike Segar/Reuters James Comey, then U.S. Attorney for the Southern District of New York, stands behind Attorney General John Ashcroft as he announces a series of indictments on April 9, 2002.

Coming out of school in New Jersey, Harvard, Princeton and Amherst “blew him off,” he told the student newspaper of the school that accepted him, William and Mary. A faculty member said that he was a finalist for a Rhodes, but didn’t get one.

But not long after the University of Chicago Law School, he aimed for the Ivy League of prosecution officers, the U.S. Attorney’s office for the Southern District of New York. He excelled there, eventually becoming the boss of that headline machine.

No one runs that shop without an exquisite understanding of politics.

For example, Comey had prosecuted financier Marc Rich, who later, as a fugitive, received a pardon from President Bill Clinton in his last day in the Oval Office. In the early years of the George W. Bush administration, Comey decided not to pursue the pardon issue.

It was a shrewd move. A registered Republican and a GOP appointee, he chose not to move on the Clintons at a time, not long after 9/11, when bipartisanship was still the theme of the day. He augmented those bipartisan credentials by threatening to quit the Bush administration in 2005 if it did not step back from domestic surveillance practices it had put in place after Sept. 11, 2001.

Somehow or other, the whole world learned of this brave act, which impressed no less of a rising figure than a new Democratic senator from Illinois named Barack Obama, who also liked to think of himself as above the partisan demimonde of D.C.

With that record, which included high-level stints as counsel to the largest defense contractor in the U.S., Lockheed Martin, and a large private hedge fund, Bridgewater Associates, Obama chose him to be FBI director in June 2013.

SAUL LOEB/Getty Images President Barack Obama looks on as James Comey is sworn in as the FBI director in a ceremony on Oct. 28, 2013.

The FBI director is nominated and confirmed for one 10-year term, in an effort to shield him or her from the daily or even yearly political winds. But the higher you go at the intersection of law and politics, the more complex the calculations become.

The investigation of Hillary Clinton’s emails has, from the start, been a test of higher math.

His first exam was last July, when, in what he clearly considered an act of even-handedness, Comey announced that, while Clinton had been “extremely careless” with classified material on her private email server, he would not recommend prosecuting her.

Republicans didn’t see that as even-handed: they saw it as letting Hillary walk. Recently, it has come out that the D.C.-based FBI leader whom Comey had allowed to be in charge of the case had close ties to the Clinton circle.

GOP House leaders had already made it clear that they were going to renew investigations of the entire email matter in the next Congress.

Central to their questioning: James Comey.

Comey was trapped. He could not risk the possibility that news of the Weiner/Abedin laptop would leak from the FBI ― or so Comey himself said in an internal explanatory letter to the agency.

But the fact that he was worried about a leak was itself an interesting commentary on the state of play within the supposedly apolitical FBI.

Now he’s trapped even more tightly. He doesn’t yet know what is on the laptop because the agency has yet to search the specific emails that he hints are in question. (The bureau obtained the needed search warrant Sunday.)

But he is facing furious demands from the Clinton camp and Democrats ― and even some Republicans ― that he lay his cards on the table, NOW.

Speaking to a reporter for his college paper, Comey in 2014 advised students to, “Try to become a quality thinker.... Life is a series of narrowing experiences, so you want to start as broad as you possibly can, before the funnel starts to narrow on you.”

Consider the funnel narrowed.

CORRECTION: A previous version of this article said that Marc Rich unsuccessfully sought a pardon from Bill Clinton; in fact, Clinton pardoned Rich on his last day in office.