Karl Racine is seen while voting at Garnet-Patterson Middle School in Washington on Tuesday. (Astrid Riecken/For The Washington Post)

District residents voted for the D.C. attorney general for the first time Tuesday, electing a longtime Washingtonian who served in the past as a public defender, White House lawyer and managing partner of one of the city’s largest corporate firms.

Karl Racine, a 51-year-old Democrat, bested his four competitors with a commanding 37 percent of more than 145,000 votes cast.

Racine topped an all-Democrat field with diverse backgrounds that included Lorie Masters, 59, a litigator for insurance claimants; Edward “Smitty” Smith, 34, the youngest candidate in the race; Lateefah Williams, 37, an openly gay African American woman; and Paul Zukerberg, 56, a criminal defense specialist. Smith, his nearest contender, won 19 percent of the vote.

As the first elected attorney general, Racine will help transform what has been regarded as an important but largely low-profile administrative job into a premier political seat in the nation’s capitol. He will succeed Irvin B. Nathan, the former general counsel for the U.S. House of Representatives who was appointed as D.C. attorney general by mayor Vincent Gray in 2011.

Sean Rankin, a Racine campaign spokesman, said that voters were impressed by the candidate’s integrity.

Local election results

“People want to have faith in their elected officials,” Rankin said. “It started with credibility and it differentiated him for the rest of the field.”

For the past four decades of self-government, the city’s top lawyer, known as “corporation counsel,” was appointed by the mayor to lead a staff of 300 lawyers in defending the District in legal matters ranging from civil rights to land use and antitrust cases.

Past appointees tapped for the position have included Ivy League-educated leaders of storied, top-ranking firms staffed with hundreds of lawyers.

Racine is no exception. During his 25-year legal career, the Penn graduate became the first African American to become a managing partner of a top 100 firm, at Venable LLP, which has 600 lawyers.

The son of Haitian immigrants, Racine grew up in the District and attended D.C. public schools before graduating from St. John’s College High School. A star athlete, he was an All-Met basketball player who later held court with the likes of Patrick Ewing and Michael Jordan in the 1981 McDonald’s Capital Classic.

He later played basketball at the University of Pennsylvania and received a law degree from the University of Virginia.

In between stints in private practice, Racine served as D.C. public defender in the early 1990s and associate White House Counsel during the second term of the Clinton administration, helping to prepare the president for depositions for independent prosecutor Kenneth Starr.

Campaigning in recent months, Racine secured endorsements from the former president and city council member Marion Barry. He also led the field in fundraising, including $500,000 from his own coffers.

Clinton said in a statement that Racine “has the integrity and ethics to be the District’s first elected Attorney General.” Barry said that Racine’s history representing the District’s poor in court earned him respect around the city.

“He understands poor people,” Barry told The Washington Post. “He and I are both tired of the city locking up all these young people for minor offenses.”

Racine’s victory Tuesday proved all the more historic considering the vote almost didn’t happen at all. Four years ago, District voters approved a measure creating the $190,000-a-year position in the D.C. government as an independent center of power to serve as a check on the mayor. But in July 2013, city council members disagreed on the scope of the new role and moved to delay a scheduled election this year.

In June, the District’s highest court ruled that the city council had acted illegally by voting to delay the first attorney general election to 2018.

DeNeen Brown contributed to this report.