New York City Public Advocate Letitia James has won the four-way race for the Democratic nomination for attorney general, taking a step toward becoming the first black woman to be elected to the post.

James faces Republican Keith Wofford, who would become the first black man elected to the job, in the November general election.

The James victory came over liberal insurgent Zephyr Teachout, Rep. Sean Patrick Maloney and Leecia Eve.

The post was unexpectedly opened in May after the resignation of Democrat Eric Schneiderman amid allegations of domestic violence and sexual misconduct.

And the result is a win for the ticket backed by Gov. Andrew Cuomo, who had supported James’s candidacy early on in the nominating process.

James has pledged to serve as a bulwark against President Donald Trump’s policies in New York, continuing much of the spirit of the work of Barbara Underwood, who was appointed by the Legislature after Schneiderman’s resignation.