“By 1908, the time was right for a new kind of agency to protect America. The United States was, well, united, with its borders stretching from coast to coast and only two landlocked states left to officially join the union. Inventions like the telephone, the telegraph, and the railroad had seemed to shrink its vast distances even as the country had spread west. . . . America was . . . a new world power on the block, thanks to its naval victory over Spain.”

— From an FBI official history

There’s a certain serendipity in President Trump’s precipitation of crisis at the Federal Bureau of investigation on the 100th anniversary of the United States’ entry into World War I.

America’s federal law-enforcement and intelligence agencies, of which the FBI (or its precursors) was among the first, took shape in the 20th century. Their rise is inseparable from that period’s dominant themes: national growth, international extension and, comparatively speaking, political consensus.

(Bastien Inzaurralde,Jayne Orenstein,Alice Li,Libby Casey,Priya Mathew/The Washington Post)

Certainly, the bitter partisanship of the 19th century, culminating in the Civil War and Reconstruction, helped prevent the development of an American counterpart to, say, the centralized detective force that Joseph Fouché built in France. No party in Congress trusted the other sufficiently to create a secret, or semi-secret, agency that might later be turned against it.

In the 20th century, Republicans and Democrats didn’t agree on much, but more often than not, they shared a sense of core national interests, and, following from that, a sense of who federal detectives and spies might appropriately target (even when that consensus led to excesses, such as CIA domestic surveillance and the FBI’s campaign against the Rev. Martin Luther King Jr.).

To the extent it guided their oversight of intelligence agencies, that baseline consensus overcame the politicians’ qualms about the undeniable tension between democratic norms on the one hand and the dark arts of surveillance on the other.

As Trump’s bold decapitation of the FBI, and the reaction to it, illustrate, however, this massive agency — 14,000 special agents, an $8.7 billion annual budget — has outlasted the national consensus that gave it life, and upon which its legitimacy ultimately rested.

We are about to learn whether such an institution can preserve its professionalism, and its ethos of nonpartisan national service, at a time when its supposed political masters have lost theirs.

It is a dangerous moment, because history shows that partisan control is the hallmark of illegitimate spying, and that politicized law-enforcement and intelligence cannot be squared with democracy.

What made East Germany’s Stasi so pernicious, for example, was not its pervasive snooping per se, but that a single political party directed the surveillance according to its own selfish interests, as defined by a constantly shifting “line.”

Trump’s ouster of FBI Director James B. Comey, amid an investigation of Russia’s meddling in the 2016 election that Trump won, reeks of self-serving political ma­nipu­la­tion, no matter how hard the president and his minions spin it as an attempt to redeem the FBI.

What’s also troubling, from the perspective of consensual governance, is that Democrats’ objections to the firing are themselves less than principled — unavoidably so, given their own grudge against Comey for rekindling the email investigation of Hillary Clinton in the final days of the campaign.

The essence of the predicament is that Comey did, indeed, play a part in the election, a fact that itself guaranteed that the winner, whoever it was, could not deal straightforwardly with him.

Imagine if it had been Clinton: What would she have done with Comey — if he didn’t resign and trigger bitter GOP resistance to the person she chose to replace him?

A big dilemma now, of course, is that anyone Trump might pick to run the FBI would carry the stigma of being selected with the same hand that dispatched Comey.

The search is on for an independent person, or group of them, to set this convoluted situation right: a special prosecutor, perhaps, or an independent commission, or aroused Senate Republicans, newly conscious of their constitutional duties.

In Washington’s not-too-distant past, such honest brokers could be readily identified and agreed upon: special prosecutor Leon Jaworski to carry on the Watergate investigation after the “Saturday Night Massacre” in 1973; or the members of the commission to investigate the terrorist attacks on Sept. 11, 2001.

Today? Not so easy. Comey, as it happens, used to be on everyone’s straight-shooter list, respected for his 2004 threat to resign unless President George W. Bush limited some surveillance Comey deemed unlawful.

In hindsight, Comey’s 2016 performance looks like an attempt to spend that moral capital on behalf of the FBI’s reputation, and his own — while politicos all about him were losing theirs and blaming it on him. Look where he is now.

Read more from Charles Lane’s archive, follow him on Twitter or subscribe to his updates on Facebook.