I first encountered Tom Perriello, who lost the Virginia Democratic gubernatorial primary, on June 13th, almost twenty years ago. I had written an article about Bill Clinton’s disastrous foreign policy in West Africa, which bolstered one of the region’s worst war criminals, President Charles Taylor, of Liberia, and strengthened his grip on neighboring Sierra Leone. Perriello read the piece and shared some of my outrage at American policy there. He called me and we chatted about the yin and yang between realism and moralism in American foreign policy. While I had written the piece entirely from a desk in Washington, Perriello was inspired to move to West Africa and work as an adviser to the prosecutor for the Special Court for Sierra Leone. The tribunal, established jointly by the U.N. and the government of Sierra Leone, was charged with prosecuting war criminals in the region’s long-running conflicts. In an audacious and controversial move, the prosecutor for whom Perriello worked unsealed an indictment against Taylor while he was visiting Ghana, making him the first sitting head of state since Yugoslavia’s Slobodan Milosevic to be indicted by an international court. Taylor fled back to the safety of Liberia, but, thanks to pressure from the Bush Administration, he stood trial and was convicted at the Special Court, in 2012. He will spend the rest of his life in jail in the U.K.

Perriello played a crucial role in bringing one of the worst murderers of the twenty-first century to justice. The next time I heard from Perriello was in late 2008, just after he won an upset victory—by less than a thousand votes—over a longtime Republican congressman from Virginia, where Perriello grew up. Perhaps being overly generous because he was an incoming member of Congress who needed media contacts, he called and reminded me that his career in public service all started with that article I had written. As a journalist, you tend not to forget those kinds of calls, and I’ve always followed his career with interest.

Perriello was swept out of office two years later, when midterm voters turned ferociously against Obama and the House of Representatives flipped into Republican hands. Obama and many of his aides retained a special affection for Perriello as someone who championed much of their ambitious early agenda despite the difficult politics of his district. He worked briefly at the Center for American Progress, a liberal think tank, before Secretary of State John Kerry brought him into the State Department, where Perriello had a notable—and under-covered—achievement late last year. He helped broker an agreement that could lead to the Democratic Republic of the Congo's first peaceful transition of power.

As he was wrapping up that work, Donald Trump was preparing to become President. Perriello decided to run for governor of Virginia—one of only two states that elects its governors in the odd year after each Presidential election and so, along with New Jersey, is often seen as the first real referendum on an incumbent President.

“The election of Donald Trump was not just some transfer of power from Democrats to Republicans,” Perriello, who is forty-two, told me earlier this week, as we discussed the lessons of his losing campaign to secure the Democratic gubernatorial nomination. “It was really the rise of at least a wannabe racial demagogue on U.S. soil. The response to that was going to be extremely important, and it was going to start in Virginia. So we closed up the peace deal in Congo at 11:00 P.M. on New Year’s Eve and launched the campaign for governor January 5th.”

Perriello lost the primary by almost twelve points. His main lesson of running for office in the era of Trump is a little surprising. “The single biggest thing that I took away from this campaign,” he said, “is that whichever party ends up figuring out how to speak about two economic issues—automation and monopoly—will not only be doing right by the country but will have a massive electoral advantage.”

In many ways, Perriello’s race in the Virginia primary was as much of a long shot as the Congo peace deal. His opponent, Ralph Northam, the lieutenant governor, was older and more established in the state. (He attended the Virginia Military Institute, while Perriello went to Yale as both an undergraduate and for a law degree.) Northam already had the backing of most top Virginia Democrats, including Governor Terry McAuliffe, one of Bill and Hillary Clinton’s closest friends, and the two Democratic senators—Tim Kaine, Hillary’s 2016 running mate, and Mark Warner.

Perriello had some other big problems. He had trouble distinguishing himself ideologically from Northam, who moved to the left on a host of issues, including adopting a minimum wage of fifteen dollars per hour, two years of free community college, and comprehensive criminal justice reform. But Northam also pilloried Perriello from the left on abortion, because Perriello once voted on an amendment during the Obamacare debate that would have prevented the use of federal funds for insurance coverage of abortions.

Perriello was also outspent and outraised. He won the backing of Elizabeth Warren, Bernie Sanders, and thirty former Obama staffers, and the primary was cast in the media as a fight between the Democratic Party’s populist and establishment wings. But the national fundraising networks of the left never adopted Perriello as a priority. (Northam had a four-million-dollar spending advantage.) Instead, most of the Netroots energy and dollars focused on the special congressional election in Georgia, where Democrat Jon Ossoff raised an astounding twenty-three million dollars but still lost. There are no limits on donations in Virginia, and Perriello relied on a few wealthy donors—or “angel investors,” as Perriello prefers to call them—who wrote six-figure checks, which was slightly awkward for the populist candidate.

Perriello also ended up losing his anti-Trump edge over Northam, an Army veteran who was originally reluctant to run as a fierce voice of #TheResistance. But in a TV ad on which he ended up spending the most money, Northam, who is a neurologist, looked straight to camera and, in a weirdly matter-of-fact way, called Trump a “narcissistic maniac.” (The ad was in heavy rotation on D.C. television, especially the cable news channels, and Trump himself, who watches hours of cable news, almost certainly would have seen it.)

Finally, the Washington Post, which endorsed Northam late in the campaign, had an enormous impact on the race. Perriello’s internal polls showed a fifteen-point swing against him in the last ten days of the race after the endorsement.

Despite the loss, Perriello thinks there are some lessons for progressive Democrats who believe that anti-Trumpism is enough to win. “I think it’s important for Democrats to keep a couple of things in mind right now,” Perriello said about what he learned. “One is not to assume that all anti-Trump energy is pro-Democratic energy. We have to go out and earn those votes. And I think, related to that, it’s important for us not just to be addressing Trump, but the forces that gave rise to Trump.”

Trump, he believes, has been the result of “a coming collision course between the rise of economic anxiety due to the disappearance of work and the persistence of structural and overt racism. One of the silliest conversations we’re having in Democratic politics is whether the Presidential election was about economic anxiety or racism. My answer to that is, ‘Yes.’ Those two have always gone hand in hand. So for us to not speak out forcefully about the structural and overt racism would be to not be doing our job as progressives, but we can’t miss the implications of a genuine shift in the economics of the United States.”

Despite being cast as the candidate of the populist left, Perriello did better with less-traditional Democratic constituencies. “We did really well with all the groups that Democrats are struggling with,” he said, “young voters, rural voters, diaspora, communities of color, voters below the age of sixty-five. And we did terribly with all the people that are going to vote with Democrats no matter what.”