D.C.’s mayor was bad.

Not in a corrupt, tainted by a campaign finance scandal way (though that’s entirely possible according to federal prosecutors) but like a naughty schoolboy getting a little bit of a rise out of an indulgent teacher. It was 10 a.m. and Vince Gray, in the middle of a political fight for his life, is going to vote at a senior center near his house in southeast Washington. The mayor is wearing a campaign t-shirt emblazoned with his name, and delicately tucks it up, exposing the midriff of his button down shirt, to avoid electioneering. The result leaves the 71-year-old looking like he’s wearing a tank top. But, as he goes and checks at the polling place and then to receive his ballot, the folded-over t-shirt slowly but surely unfolds, revealing more and more of his name. As the metropolitan media gathers around him, he tells the woman handing him his ballot: “I want to vote for number six on the ballot for mayor. Can you tell me who it is?” She somewhat perplexedly counts down for the incumbent seeking a second term in City Hall who crows that yes, it is Vincent C. Gray. “I think I’ll vote for Vincent C. Gray,” he proclaims. Then off he goes to a neighboring booth and does precisely that.

But, not enough other Washington voters did on Election Day and the incumbent Democratic mayor lost by margin of about 44-33 to Muriel Bowser, an African-American city councilwoman from a majority black district spanning the northernmost part of the city.

Gray should have been a shoo-in. Washington, D.C. is perhaps as prosperous as it’s been since Pierre Charles L’Enfant decided to lay down a city grid in a fetid swamp along the Potomac two centuries ago. Crime is plummeting and real estate prices are starting to approach New York levels as entire neighborhoods of bougie restaurants and trendy bars seem to pop up overnight. But Gray has been torpedoed by an ongoing federal investigation of 2010 campaign for mayor where he allegedly relied on an illegal “shadow campaign” to knock off incumbent Mayor Adrian Fenty. The investigation, which started in 2011, ensnared a number of Gray’s campaign aides. The original investigation started with charges that his 2010 campaign provided money to a candidate whose only purpose in the race was to attack Fenty at candidate’s forums. The investigation has since expanded dramatically.

Prosecutors now allege that Washington businessman Jeffrey Thompson, nicknamed “Uncle Earl” by Gray, funneled over half a million dollars to Gray during his 2010 campaign as well as cash to both a close friend and a relative of Gray. In a plea deal before the election, Thompson pled guilty on two counts of conspiring to violate campaign finance law and implicated Gray in doing so. Although Gray has denied all the allegations against him, the ongoing whiff of scandal greatly weakened the mayor’s political fortunes.

The result forced the incumbent, who worked with the developmentally disabled and started a nonprofit for homeless youth before running for office, to double down on appealing to his African-American base. Gray touted the support of former mayor Marion Barry and redoubled his efforts in the almost entirely black neighborhoods east of the Anacostia River. At one campaign stop Monday there, the mayor emerged his black SUV to shake hands with voters while, across the street, a mini-van, converted to a sound truck for the day, blared the Delfonics and go-go music when not broadcasting messages of support for Gray,

Outside a polling place in Fairfax Village, a predominantly African-American neighborhood of brick detached homes in southeast DC on Tuesday, this mixed legacy on full display. Darnell Butler, who recently moved back to Washington from Maryland, said he was voting for Bowser. He told The Daily Beast that “it was time for a change” and that he was concerned about the criminal allegations surrounding Gray. However, he said he was “pretty much” happy with Gray’s stewardship of the city and had even recently moved back to the District as a result of the area’s improvement.

But, at Gray’s election night party, Marion Barry (who knows a bit about investigations) pooh-poohed the impact of the scandal before the results came in. While Barry was outraged that prosecutors waited to trot out Thompson until only three weeks before the election, “the Mayor for Life” was also skeptical about whether the accusations would have a major electoral impact. In particular, he scoffed at whether Gray’s political standing would be damaged among white voters. Barry noted that the now incumbent only got “17% [of the white vote] when Vincent Gray was Mr. Clean and white people don’t like what they perceive as corruption.” The former four-term mayor insisted, “There is no corruption in DC government. The only corruption that did happen was the shadow campaign. Vince Gray has done an excellent job.”

Yet, for all the benefits of incumbency—including one voter who told The Daily Beast that she voted for Gray in part because she got new trash cans from the city—the scandal ended up dragging down in the opinion of Gray’s campaign manager Chuck Thies. The veteran political operative, while brandishing a Sierra Nevada after Gray’s concession speech, told reporters that the only thing that changed in the entire course of the campaign was Jeff Thompson’s plea deal. In Thies’s opinion, the U.S. Attorney for the District of Columbia, Ron Machen, deliberately timed the announcement of the deal in order to alter the election results. He maintained, if not for that, Gray would have won re-election handily.

Strangely for the staunchly Democratic city, there may be a competitive general election in November. David Catania, a white, openly gay city councilman who left the GOP in protest over social issues is considered to have a shot at winning election. In Gray’s concession speech, the incumbent mayor was coy about whom he might back, saying only “we ought to work hard to make sure the best candidate emerges to be the next mayor.”

After he conceded, Gray took a few questions and slowly swerved his way through the oversized hotel ballroom, where his election night event was held. He stopped to chat with and hug supporters. While he was doing that, Marion Barry was still holding court for a swarm of reporters back towards the stage. Washington politics had changed.

While Barry was able to constantly win re-election despite his personal peccadilloes (the only race he ever lost came shortly after being sentenced to six months in federal prison), Gray couldn’t pull off re-election because of a whiff of scandal, let alone an indictment and conviction. Despite a city on the upswing and the ability to reel off statistic after statistic to demonstrate that things were as good as they appeared to the casual observer, Gray still lost handily. It seems, almost two decades after Barry’s last term in office, it is no longer good to be bad in local Washington politics.