In recent years, as I finished writing a biography of J. Edgar Hoover, director of the F.B.I. for nearly half a century, liberal-minded friends often came to me with a confession. They were, they whispered, cheering for the F.B.I. During the Trump era, they began to see the bureau as the last best hope of the Republic, after a lifetime of viewing it as a bastion of political repression.Public opinion polls bear out this shift in opinion. In 2003, Republicans liked the F.B.I. far better than Democrats did, by a margin of 19 points, at 63 percent to 44 percent. Today, nearly 20 years later, that equation has flipped and then some. According to a recent Rasmussen survey, 75 percent of Democrats now have a favorable view of the F.B.I., in contrast to 30 percent of Republicans. Gallup puts the numbers further apart, with 79 percent of Democrats expressing approval and 29 percent of Republicans disapproval.From James Comey’s firing in May 2017 through the Mueller report, the Jan. 6 investigation and the Mar-a-Lago raid, the F.B.I. has not always delivered on Democratic hopes. But its showdowns with Donald Trump have fundamentally changed its public image.To some degree this switch simply reflects our hyperpartisan times. But the F.B.I.’s surge in popularity among Democrats also reflects a forgotten political tradition.Since the 1960s, liberals have tended to associate the bureau with its misdeeds against the left, including its outrageous efforts to discredit the Rev. Dr. Martin Luther King Jr., and other civil rights activists. Before those activities were exposed, though, liberals often admired and embraced the F.B.I., especially when it seemed to be a hedge against demagogy and abuses of power elsewhere in government.They pointed to the bureau’s role as an objective, nonpartisan investigative force seeking to ferret out the truth amid an often complicated and depressing political morass. And they viewed Hoover as one the greatest embodiments of that ethic: a long-serving and long-suffering federal civil servant who managed to win the respect of both Republicans and Democrats.The Rev. Dr. Martin Luther King Jr. leaving the office of J. Edgar Hoover in 1964. The F.B.I. conducted extensive surveillance of Dr. King’s private life.Bettmann/Getty ImagesWe now know that much of that admiration rested on wishful thinking — and today’s liberals would be wise to remember Hoover’s cautionary example. But for all his failings, all his abuses of power, he also promoted a vision of F.B.I. integrity and professionalism that still has resonance.J. Edgar Hoover was a lifelong conservative, outspoken on matters ranging from crime to Communism to the urgent need for all Americans to attend church. He also knew how to get along with liberals. Indeed, he could not have survived in government as long as he did without this essential skill. First appointed bureau director in 1924, Hoover stayed in that job until his death in 1972, an astonishing 48 years. He served under eight presidents, four Republicans and four Democrats.It has often been said that Hoover remained in power for so many decades because politicians feared him — and there is much truth to that view, especially in his later years. But Hoover’s late-in-life strong-arm tactics do not explain much about how he rose so fast through the government ranks, or why so many presidents — including Franklin Roosevelt, the great liberal titan of the 20th century — thought it was a good idea to give him so much power.Hoover spent his first decade as director establishing his good-government bona fides; he championed professionalism, efficiency, high standards and scientific methods. So in the 1930s, Roosevelt saw Hoover not as a far-right reactionary but as an up-and-coming administrator thoroughly steeped in the values of the modern state — a bureaucrat par excellence.Roosevelt did more than any other president to expand the F.B.I.’s power: first, by inviting Hoover to take a more active role in crime fighting, then by licensing him to become the nation’s domestic intelligence chief. Hoover’s agents became known as G-men, or government men, the avenging angels of the New Deal state.Hoover, center, taking aim while giving the Broadway actors flanking him, William Gaxton and Vincent Moore, a tour of F.B.I. headquarters in 1935.Underwood and UnderwoodToday’s F.B.I. still bears the stamp of the decisions Roosevelt made nearly a century ago. A hybrid institution, the F.B.I. remains one part law-enforcement agency, one part domestic-intelligence force — an awkward combination, if one that we now take for granted.It also retains Hoover’s dual political identity, with a conservative internal culture but also a powerful commitment to professional nonpartisan government service. This combination of attributes has helped to produce the F.B.I.’s inconsistent and sometimes contradictory reputation, as different groups pick and choose which aspects to embrace and which to condemn.Hoover went on to do outrageous things with the power granted him during the Roosevelt years, emerging as the 20th century’s single most effective foe of the American left. But many Washington liberals and civil libertarians did not see those abuses coming, because Hoover continued to reflect some of their values as well. During World War II, he distinguished himself as one of the few federal officials opposed to mass Japanese internment, labeling the policy “extremely unfortunate” and unnecessary for national security.After the war, despite his deep-seated racism, he stepped up the F.B.I.’s campaign against lynching in the South. “The great American crime is toleration of conditions which permit and promote prejudice, bigotry, injustice, terror and hate,” he told a civil rights committee convened by President Harry Truman in 1947. He framed white supremacist violence not only as a moral wrong but also as an acute challenge to federal authority.By contrast, he promoted himself as the embodiment of professional law enforcement, the polar opposite of the Ku Klux Klan’s vigilantes or the conspiracists of the John Birch Society. Many liberals embraced that message, despite Hoover’s well-known conservatism. “If a liberal came in, the liberal would leave thinking that, ‘My God, Hoover is a real liberal!” William Sullivan, an F.B.I. official, recalled. “If a John Bircher came in an hour later, he’d go out saying, ‘I’m convinced that Hoover is a member of the John Birch Society at heart.’ ”The height of Hoover’s popularity came during the Red Scare of the 1950s, when he emerged as both a hero of the anti-Communist right and the thinking man’s alternative to Senator Joseph McCarthy. Today, we tend to view Hoover and McCarthy as interchangeable figures, zealots who ran roughshod over civil liberties. At the time, though, many liberals viewed them as very different men.Truman feared the F.B.I.’s “Gestapo” tendencies, but far preferred Hoover to a partisan brawler and obvious fabricator like McCarthy. President Dwight Eisenhower heaped lavish praise on Hoover as the nation’s responsible, respectable anti-Communist, in contrast to McCarthy the demagogue. Both presidents cast the story in terms that might be familiar to any 21st-century liberal, with Hoover as the protector of truth, objectivity and the law, and McCarthy as those principles’ most potent enemy.One irony of the liberals’ stance is that it was actually Hoover, not McCarthy, who did the most to promote and sustain the Red Scare. Long before McCarthy burst on the scene, Hoover had been collaborating with congressional committees to target Communists and their sympathizers, conducting elaborate campaigns of infiltration and surveillance. And he long outlasted McCarthy, who was censured by his fellow senators in 1954. Hoover’s popularity grew as McCarthy’s fell. A Gallup poll in late 1953, the peak of the Red Scare, noted that a mere 2 percent of Americans expressed an unfavorable view of Hoover, a result “phenomenal in surveys that have dealt with men in public life.”Hoover with President Richard Nixon in 1969.Bettmann Archive, via Getty ImagesAnd with President Lyndon B. Johnson in 1965.Associated PressThat consensus finally began to crack in the 1960s. Hoover’s current reputation stems largely from this late-career period, when the F.B.I.’s shocking campaigns against the civil rights, antiwar and New Left movements began to erode earlier conceptions of Hoover as a man of restraint.Its most notorious initiative, the bureau’s COINTELPRO (short for Counterintelligence Program), deployed manipulative news coverage, anonymous mailings and police harassment to disrupt these movements. In 1964, in one of the lowest points of Hoover’s regime, the F.B.I. faked a degrading anonymous letter implicitly urging Dr. King to commit suicide. Agents mailed it to him along with recordings of his extramarital sexual activities, captured on F.B.I. microphones planted in his hotel rooms.Even then, though, key liberal figures continued to champion Hoover and the F.B.I. President Lyndon Johnson, a friend and neighbor of Hoover’s, proved second only to Roosevelt in his enthusiasm for the director. And he urged his successor, Richard Nixon, to follow suit. “Dick, you will come to depend on Edgar,” he told Nixon in the Oval Office in late 1968. “He’s the only one you can put your complete trust in.”Despite such official support, by the early 1970s polls were starting to note that Hoover’s reputation among liberals and Democrats seemed to be in swift decline, thanks to his advancing age, aggressive tactics and conservative social views. “Now the case of J. Edgar Hoover has been added to the list of issues — ranging from the war in Vietnam, to race relations, welfare and the plight of the cities — which are the source of deep division across America today,” the pollster Louis Harris wrote in 1971.While conservatives still expressed widespread admiration for the F.B.I. director, liberals increasingly described him as a danger to the nation. The decline was especially precipitous among coastal elites and university-educated young people. By contrast, working-class white Americans in the Midwest and South expressed support.Today, those sentiments are reversed. According to Rasmussen, the F.B.I. is now most popular among Americans making more than $200,000 per year. Young voters like the F.B.I. better than older voters do. This division is being driven by national politics: When Mr. Trump attacks the F.B.I. as part of an overweening “deep state,” his supporters follow while his critics run the other way.But it also reflects a larger clash of values. Mr. Trump has long scored political points by attacking the administrative state and its legions of career government servants, whether at the F.B.I., the C.I.A., the State Department or, improbably, the National Archives. In response, Democrats have been forced to reaffirm what once seemed to be settled notions: that expertise and professionalism matter in government, that the rule of law applies to every American, that it’s worth employing skilled, nonpartisan investigators who can determine the facts.Hoover failed to live up to those principles — often spectacularly so. And today’s F.B.I. has made its own questionable choices, from surveillance of Black Lives Matter protesters to mismanagement of delicate political inquiries. But its history of professional federal service, of loyalty to the facts and the law, is still worth championing, especially in an era when suspicion of government, rather than faith in its possibilities, so often dominates our discourse. Whatever else we may think of Hoover’s legacy, that tradition is the best part of the institution he built.Beverly Gage (@beverlygage) is a professor of American history at Yale and the author of “G-Man: J. Edgar Hoover and the Making of the American Century.”The Times is committed to publishing a diversity of letters to the editor. We’d like to hear what you think about this or any of our articles. Here are some tips. And here’s our email: letters@nytimes.com.Follow The New York Times Opinion section on Facebook, Twitter (@NYTopinion) and Instagram. More