NEW YORK (AP) — Letitia James, a longtime New York City politician with ties to both the state's underclass and its elites, beat three other candidates in a Democratic primary for attorney general, then turned her sights on the man she saw as her real opponent: President Donald Trump.

"This campaign was really never about me, or any of the candidates who ran," James told supporters at her Thursday victory party in Brooklyn. "It was about the people, but most importantly it was about that man in the White House who can't go a day without threatening our fundamental rights, can't go a day without threatening the rights of immigrants, can't go a day without dividing us."

For the 59-year-old former public defender, history is at stake, too. She would become the first black woman to hold a statewide elected office in New York if she prevails in the general election, where she will be heavily favored.

She would also become the first woman elected attorney general, though not the first to hold the job. The current attorney general, Democrat Barbara Underwood, was appointed after Trump nemesis Eric Schneiderman, a Democrat, abruptly resigned in May amid allegations he physically abused women he dated. Underwood declined to run for election.

"This is a historic moment, it shows that there's room for all of us at the table," James supporter Michelle Gilliam said. "As a black woman, Tish elevates and inspires black women everywhere. I've been following her career since the beginning and watching her progress has been a beacon of hope for me and all women of this community."

James defeated a deep field of fellow Democrats: U.S. Rep. Sean Patrick Maloney, Fordham law professor Zephyr Teachout and former Hillary Clinton adviser Leecia Eve. She said she wouldn't let campaign rivalries get in the way of their friendships or impede their ability to work together to keep Trump in check.

New York's attorney general has long had an unusual role as a regulator of Wall Street and an occasional prosecutor of the rich and powerful. The office also recently opened an investigation of sexual abuse within the Roman Catholic Church. But in this contest, Trump emerged as the common foe among all the candidates.

"We are in the middle of a fight to save our democracy," she said. "Let's party tonight and then we've got some work to do tomorrow."

The winner in November will inherit several pending lawsuits filed by the state that challenge Trump's policies and accuse his charitable foundation of breaking the law.

James faces little-known New York City lawyer Keith Wofford, who ran unopposed in the Republican primary, in the general election in November.

Wofford, in a statement, criticized James as a "career politician" who will "uphold the corrupt status-quo." He pitched himself as an "independent outsider" and said he'd do what's in the state's best interests.

James served as New York City's elected public advocate after a decade on the City Council and stints as a public defender and assistant attorney general. She was an early favorite in a race that tightened over the summer, picking up endorsements from Democratic Gov. Andrew Cuomo and several powerful unions. Rapper Nicki Minaj plugged her on Twitter the night before the election.

As public advocate, James said she transformed the office from its traditional role as an ombudsman on issues of public concern to a "mini-legal services slash attorney general's office."

She lobbied for police officers to wear body cameras and for special prosecutors to be appointed in police misconduct cases. Her office maintains a list of the "worst landlords" in the city and has pushed to expand tenant protections.

James entered her victory party to the sounds of a DJ playing "All the Way Up" by Fat Joe and Remy Ma. She dedicated her victory to "every little girl who has been told she cannot change the world" and singled out an 87-year-old supporter who cast her first vote decades ago in the Jim Crow south.

Underwood congratulated the candidates in a tweet before the polls closed for showing they "believe in the power of this office" and for giving voters "a choice for the future."

"After the events of this year, I hope it is clear to everyone that this office is the sum of all its staff," Underwood tweeted. "I am so proud to be your AG."

Trump's lawyers have argued that the attorney general's office was unfairly politicized under Underwood and Schneiderman.

The adversarial relationship dates back to 2012, when Schneiderman sued Trump University, claiming the school defrauded students. Trump settled litigation related to the school for $25 million, saying he was doing so only so he could keep his attention focused on national issues.

In defending the state's lawsuit against the Trump Foundation, Trump's lawyers said New York built its case on minor, unintentional bookkeeping violations and unnecessarily blocked the charity from shutting down simply so it could continue to assail it in court.

The legal sparring is likely to continue. The attorney general's office has lawsuits pending against Trump administration policies on health care, guns, immigration and the environment.

Letitia James delivers a victory speech after winning the primary election for attorney general Thursday, Sept. 13, 2018, in New York. James would become the first black woman to hold statewide elected office in New York if she prevails in the general election. (AP Photo/Kevin Hagen)

Letitia James delivers a victory speech after winning the primary election for attorney general Thursday, Sept. 13, 2018, in New York. James would become the first black woman to hold statewide elected office in New York if she prevails in the general election. (AP Photo/Kevin Hagen)

State attorney general candidate Zephyr Teachout delivers her concession speech at the Working Families Party primary night party, Thursday, Sept. 13, 2018, in New York. New York City Public Advocate Letitia James defeated a deep field of fellow Democrats: U.S. Rep. Sean Patrick Maloney, Fordham law professor Teachout and former Hillary Clinton adviser Leecia Eve. (AP Photo/Jason DeCrow)

Supporters celebrate after the Democratic primary for attorney general was called in favor of Letitia James Thursday, Sept. 13, 2018, in New York. The 59-year-old was an early favorite in the race after getting endorsements from Gov. Andrew Cuomo and other top Democrats. (AP Photo/Kevin Hagen)

Supporters celebrate after the Democratic primary for attorney general was called in favor of Letitia James Thursday, Sept. 13, 2018, in New York. (AP Photo/Kevin Hagen)

Letitia James delivers a victory speech after winning the primary election for attorney general Thursday, Sept. 13, 2018, in New York. The 59-year-old was an early favorite in the race after getting endorsements from Gov. Andrew Cuomo and other top Democrats. (AP Photo/Kevin Hagen)

ATLANTA (AP) — Stacey Abrams broke the rules of politics until the very end.The Georgia Democrat who came about 60,000 votes shy of becoming America's first black female governor refused to follow the traditional script for defeated politicians who offer gracious congratulations to their victorious competitor and gently exit the stage.

NEW YORK (AP) — Even before they announce their White House intentions, New Hampshire's ambitious neighbors are in the midst of a shadow campaign to shape the nation's first presidential primary election of the 2020 season.

TALLAHASSEE, Fla. (AP) — Democratic Sen. Bill Nelson, a Florida political icon whose career highlight may have been a trip on the space shuttle, conceded his bitterly close re-election bid to Republican Rick Scott on Sunday, ceding a razor-thin race to the outgoing governor after a tense and sometimes turbulent recount.

TALLAHASSEE, Fla. (AP) — Andrew Gillum, who tried to energize Florida's young and minority voters through a Democratic coalition seeking to end two decades of Republican control of the governor's office, ended his hard-fought campaign Saturday as the state's first black nominee for the post.

TALLAHASSEE, Fla. (AP) — Andrew Gillum, who tried to energize Florida's young and minority voters through a Democratic coalition seeking to end two decades of Republican control of the governor's office, ended his hard-fought campaign Saturday as the state's first black nominee for the post.