To most people outside Washington, D.C., and to many living there now, former Mayor Marion Barry's political appeal remains a mystery. To them, he is a national embarrassment, the big-city mayor who ran America's glittering national capital into the ground, the guy who was dumb enough to get caught on tape smoking crack while still in office.

But the Barry who was elected mayor four times, including once after that crack conviction, owed his success to being an unparalleled retail politician who could mollify the city's powerful business interests, isolate political opponents, and make the city's working class and poor believe he spoke for them. He was a master at exploiting black racial anxieties, which makes him different from many of America's most successful politicians only in that his constituency, and therefore his culture war appeals, were black. Within the city, he was a champion who first gave its working-class black residents a taste of the economic prosperity that racial apartheid had long denied them. He was the realization of D.C. residents' long-denied democratic aspirations. There is much more to Barry than the time he got set up.

From the outside, observers could see only Barry's flaws, his corruptions and addictions. The mystery of Barry's political survival despite numerous run-ins with the law, mismanagement of the city government, and numerous allegations of sexual assault is easier to solve if you know the history of the city. Barry didn't bring corruption to D.C. He changed who benefited from it.

That history, immaculately chronicled by Harry Jaffe and Tom Sherwood in Dream City, begins with a century of the town once known as "Chocolate City" being run by hardcore white supremacists in Congress. Jaffe and Sherwood quoted former Confederate General and long-serving Alabama Sen. John Morgan declaring in 1890 that the city could not have an elected government because of its large black population. To save the city, Congress had to "get rid of this load of negro suffrage that was flooded in upon them."

If we understand segregation as, in Ta-Nehisi Coates' words, "legalized theft," then D.C. was largely run by white supremacist robber barons in Congress who for a hundred years were dedicated to keeping its black residents mired in crushing poverty.

President Dwight Eisenhower ordered the city's public facilities desegregated in the 1950s, but racist Southern Democrats maintained their control of the city from Congress. Overcoming resistance from Republicans, Southern Democrats, and entrenched business interests, President Lyndon Johnson pushed a bill through Congress allowing an appointed mayor and city council that paved the way for home rule — the white elite in the city, including, Jaffe and Sherwood note, Washington Post publisher Katharine Graham and editor Ben Bradlee, urged Johnson to appoint a white mayor.

Johnson resisted that impulse and appointed Walter Washington, who was easily defeated by Marion Barry in the city's second elections in 1978. Rep. John McMillan, the Dixiecrat who chaired the House Committee on the District of Columbia until 1973, sent Washington a truckload of watermelons to "celebrate" his receipt of Washington's first city budget. McMillan "treated the city as if it were his plantation and turned the District Building into a fiefdom for his own patronage jobs," applying "applied taxes to construction projects at the behest of the white business community," Jaffe and Sherwood wrote.

This is the kind of person who was managing Washington's affairs until the 1970s.

Barry was famously born the child of sharecroppers in Mississippi, he played an important role in the Student Nonviolent Coordinating Committee, organizing the sit-in movement that helped take down Jim Crow. Barry had become enamored of the city and abandoned national politics to work towards self-determination for D.C.

Though he was an educated man with a degree in chemistry, through years of organizing in the city around home rule, police brutality, and working with the federal government to bring jobs to the city's poorest, he had cultivated a power base. One of Barry's earliest campaigns in the District was protesting over the police killing of an unarmed black teenager, who had been shot in the back by a police officer after buying cookies.

Despite his image as a corrupt radical, Barry won his first term as mayor not just with the backing of the city's black poor and working class, but with wealthy business interests. Barry, Jaffe and Sherwood note, even had the backing of the police union in 1978. That's despite two altercations with police in the 1960s once with a police officer who called him "boy" and arrested him for jaywalking, another with police who tried to give him a ticket. Barry told the cop, "if you put a ticket on my car, I'll kill you." Whatever one thinks of Barry's behavior--his bravery in his interactions with police in the 1960s is astonishing.

Barry's ability to play — no, be the radical when it suited him and compromise with the powers that be when it was in his interest to do so is a key reason why he was able to maintain power and defy political defeat. You could call this pragmatism; Barry had another word for it. "I'm a situationist," he told the Washington Post in 1978. "I do what is necessary for the situation."

Despite his reputation for daishiki-clad raised-fist radicalism, Jaffe and Sherwood wrote that the true beneficiaries of Barry's terms in office were wealthy business interests, particularly in real estate. "No matter how many millions of dollars in city contracts flowed to Barry's friends, it was chump change compared to the hundreds of millions of dollars that enriched the white community during the real estate boom," they wrote.

Nevertheless, for the first time, black residents of the District were receiving some of the spoils. Barry's administration was the first time blacks took leadership of a city in which they had been a majority for years.

For thousands of people in the District, Marion Barry was the reason they had a job, which meant he was the reason they could keep their home, feed their children, or keep their lights on. Poor and working-class kids in the city have been getting their first jobs from Barry's summer jobs program for thirty-five years. His administration increased assistance to the elderly and the poor. If you didn't personally benefit from the way Barry ran the city, you probably knew someone who did. People in D.C. loved Marion Barry because they felt like he made their lives better.

This should sound familiar, because the tricklings of New Deal initiatives that reached the black community in the 1930s and '40s were the reason black voters suddenly invested in a party that, up until then, had been defined largely by its implacable devotion to white supremacy. If people believe a politician has materially improved their lives, it establishes a loyalty that is hard to break.

To outsiders, Barry's political patronage was corruption — and it was. But it also seemed as if the same people who had tried to disenfranchise the city's black population, who never wanted black people to have any influence on the way the city was governed, were suddenly behaving as if Barry had invented ethnic patronage, as if it hadn't been a way of life for whites in ethnic enclaves in big cities from New York to Illinois to California. As if the white segregationists who ran the city "like a plantation" were not corrupt.

Barry was elected mayor of D.C. only about 13 years after the Voting Rights Act guaranteed blacks the right to vote all over the country. Lurking beneath the criticism of Barry and the way the city was run, D.C. residents feared that the same people who never wanted blacks to vote in the first place would somehow take the city away from them. Barry had to succeed to defy the racists who argued, once explicitly and now through euphemism, that blacks could not be trusted to govern themselves. America took more than two centuries to begin to get democracy right, but D.C. home rule was supposed to be a failure after less than a decade?

So by the time the feds closed in on Barry smoking crack in the Vista hotel room in 1990, following years of federal surveillance, District residents already had the feeling that the authorities had it in not just for Barry, but for the city itself. As Barry once put it defending Harlem Rep. Adam Clayton Powell, "Regardless of whether Adam Clayton Powell is good or bad ... regardless of whether he is flamboyant or not, regardless of whether he goes to Bermuda or not, we should all support him in this issue because he is being attacked by racists."

Barry's administration was corrupt, he had mismanaged the city, and it was suffering greatly from the the violence of the crack era. But the more he was attacked, the more his most loyal constituents rallied to his side. So it's no wonder that in 1994, just a few short years after his arrest, Barry ran for mayor again, successfully, and he represented the residents of D.C.'s Ward 8, among the most impoverished in the city, until his death.

The crack wars are over, and a wealthy, white, liberal creative class is displacing the city's black majority — the modern American economy has done what many of the city's black residents have long feared would be achieved by conspiracy. The identity politics that Marion Barry practiced no longer work here, even though the appeals to the city's business interests still do. Marion Barry died long after the city that once elected him had largely ceased to exist.

But the parts of it that still do will never, ever be ashamed of him. He will always be Mayor Barry.

Adam Serwer is the national editor for BuzzFeed News and is based in Washington, D.C. His secure PGP fingerprint is 883A 7AB8 4736 1BB9 A061 D26A F2B5 71C0 391A 0252