A civil rights lawyer who has defended Black Lives Matter and Occupy Philadelphia protesters is poised to become Philadelphia's next district attorney.

Larry Krasner has never worked as a prosecutor but benefited from a $1.5 million donation from liberal billionaire George Soros to an independent political action committee that ran commercials and sent out canvassers in support of his candidacy.

Krasner pulled ahead in a crowded field to win the Democratic nomination Tuesday over several veteran prosecutors and a former city manager. He will face the only Republican candidate, Beth Grossman, in the fall.

The victory followed an intriguing campaign as eight newcomers vied for a job that helps shape city policy on sanctuary cities, police use of force, prison reform and other national issues.

The candidates hoped to succeed two-term incumbent Seth Williams, who goes on trial next month in a federal bribery case. They included a Pakistani-American, a Cuban-American, a black Muslim and Krasner, who also got a nod from singer-songwriter John Legend, a graduate of the University of Pennsylvania.

Several supported prison and bail reform and prisoner re-entry programs, despite efforts under U.S. Attorney General Jeff Sessions to return to the era of long prison terms for drugs and other crimes.

The other Democrats included Joe Khan, a former city and federal prosecutor; Rich Negrin, a former city prosecutor and city managing director; and Tariq El-Shabazz, who did a stint as Williams' top assistant.

One "juvenile lifer" released this year after serving 41 years in prison for a killing committed when he was 17 was out canvassing on Election Day, urging voters to support justice reform efforts. Michael Twiggs, 59, was taking part in a project run by the American Civil Liberties Union.

"If we get a D.A. in place who will be somewhat compassionate, not so eager to throw lives away, who would be fair," Twiggs said last week, "then I think that ... we'll be getting a better outcome."

In the city controller's race, Rebecca Rhynhart defeated incumbent Alan Butkovitz for the Democratic nomination.