Democrat Letitia James was elected the state’s next attorney general on Tuesday, handily defeating Republican Keith Wofford.

James’s victory is a history-making one: She is the first black woman to be elected to the post, the state’s chief legal officer.

The attorney general’s office was open for the first time since 2010 due to the resignation in May of Eric Schneiderman, a Democrat who was accused by multiple women of sexual abuse and violence.

James is taking the helm of an office that has morphed from a sleepy post that largely represents the state’s executive branch agencies in lawsuits to the sheriff of Wall Street, a policer of Albany corruption, to one that has come to act as a national counterbalance to President Donald Trump’s administration.

James’s political journey is one that has been on a consistently upward trajectory, from her time as an aide to Democrats in the state Senate, taking her to a city Council seat and the post of New York City public advocate.

In that office, James had considered a potential successor to New York City Mayor Bill de Blasio.

But then Schneiderman’s swift and sudden downfall came.

James was the victor of a four-way Democratic primary bid that came with the backing of Gov. Andrew Cuomo, who was also locked in a head-to-head primary against Cynthia Nixon.

She’s taking over an office that has transformed over the years to a powerful and prominent position, with its occupant considered a potential governor — with jokes that “AG” stands for “aspiring governor” coming with the territory.

James’s immediate predecessor is Barbara Underwood, a low-key and longtime attorney who had been solicitor general until she was confirmed by the Legislature to act as a placeholder. Underwood declined to run for a full term.