D.C. Attorney General Karl Racine (D) at a June 2017 news conference. (Michael Robinson Chavez/The Washington Post)

D.C. Attorney General Karl Racine (D) announced Friday that he will run for reelection to his current seat, putting an end to widespread speculation that he might challenge Mayor Muriel E. Bowser (D) in 2018.

Racine's decision, which he disclosed during an appearance on "The Kojo Nnamdi Show" on WAMU-88.5, eases Bowser's path toward keeping her job leading the city. It comes after a Washington Post poll in June showed Racine trailing Bowser by a 40-point margin among registered Democrats in a hypothetical mayoral race.

"I've decided that's what's most important to me is to continue to serve as attorney general," Racine said. "Thinking about leaving prior to finishing a job was not appealing. . . . I think I need another term to really build that office in a way that's going to make the city proud."

Racine said he had communicated his decision to Bowser and that "she was incredibly pleasant and gracious." He declined to say whether he would endorse Bowser's reelection bid, which she is expected to announce this fall.

While Racine was a long-shot prospect in the 2018 mayor's race, his choice not to run will likely be welcomed by Bowser's camp. A former criminal-defense attorney with strong ties in the District's deep-pocketed legal community, Racine has a compelling personal story — he emigrated from Haiti as a child — and has begun to attract attention as he and other state attorneys general take on the Trump administration over its immigration policies.

Racine is also helping to lead the push for legislation that would ban companies that do business with the city from contributing to city political campaigns, addressing long-standing concerns over "pay-to-play" politics in the District.

Nevertheless, the June Post poll showed the attorney general struggling with a lack of name recognition among D.C. voters, with 74 percent saying they had no opinion of him.

With nine months to go before the June 2018 Democratic primary that is normally decisive for the general election in left-leaning D.C., much could happen to change the contours of the race. But at present, Racine's announcement leaves Bowser with a sole potential challenger waiting in the wings: D.C. Council member Vincent Gray (D-Ward 7), a former mayor whom Bowser unseated in 2014.

While Gray remains popular with his base in Wards 7 and 8, he would likely struggle to overcome lingering distrust in other parts of the city from a federal investigation into his 2010 mayoral campaign. That investigation, focused on $653,000 in illegal spending on Gray's behalf by former city contractor Jeffrey E. Thompson, netted guilty pleas from six people, including Gray associates.

Gray was never charged and said he was unaware of illegal activity. He has attributed his 2014 loss to Bowser to negative publicity from the investigation.

Gray could not immediately be reached for comment. His former campaign manager, Chuck Thies, said Gray "has no set timeline" for making a decision about the mayor's race and is currently "focused on getting back to work at the council."