Letitia James has seen off three Democrat rivals to secure the party’s nomination as New York state’s next attorney general.

Her victory with 40.5 per cent of the vote puts her on course to become the first black woman elected to office to represent the state.

Following her win, she immediately turned her attention to the person she sees as her real opponent — Donald Trump.

“This campaign was really never about me, or any of the candidates who ran,” Ms James told supporters at her victory party in Brooklyn on Thursday.

“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.”

The role of attorney general in New York has a long history as an office used to regulate Wall Street and prosecute rich and powerful figures.

If Ms James beats her Republican opponent in November’s general election, she will inherit several pending lawsuits filed by the state that challenge Mr Trump’s policies and accuse his charitable foundation of breaking the law.

“We are in the middle of a fight to save our democracy,” the 57-year-old said. “Let’s party tonight and then we’ve got some work to do tomorrow.”

She faces little-known New York City lawyer Keith Wofford, who ran unopposed in the Republican primary. Voters are expected to heavily favour Ms James.

If elected, she would also become the first woman elected to be attorney general, though she would not be the first woman to hold the job.

The current attorney general, Democrat Barbara Underwood, was appointed after Trump nemesis Eric Schneiderman, also a Democrat, abruptly resigned in May amid allegations he physically abused women he dated.

Ms Underwood has declined to run for election.

What senior White House official wrote the New York Time op-ed Show all 5 1 /5 What senior White House official wrote the New York Time op-ed What senior White House official wrote the New York Time op-ed James Mattis ARLINGTON, VA - AUGUST 28: U.S. Secretary of Defense James Mattis speaks to members of the press before a press briefing at the Pentagon August 28, 2018 in Arlington, Virginia. Mattis held the briefing with Chairman Of The Joint Chiefs of Staff Gen. Joseph Dunford. (Photo by Zach Gibson/Getty Images) Zach Gibson Getty What senior White House official wrote the New York Time op-ed Jeff Sessions WASHINGTON, DC - AUGUST 31: Attorney General Jeff Sessions stands with fellow administration officials and quests during the memorial service for Sen. John McCain, R-Ariz., in the Capitol Rotunda where he will lie in state at the U.S. Capitol, on August 31, 2018 in Washington, DC. The late senator died August 25 at the age of 81 after a long battle with brain cancer. He will lie in state at the U.S. Capitol, a rare honor bestowed on only 31 people in the past 166 years. Sen. McCain will be buried at his final resting place at the U.S. Naval Academy. (Photo by Ken Cedeno-Pool/Getty Images) Pool Getty Images What senior White House official wrote the New York Time op-ed Don McGahn White House Counsel Don McGahn listens during the confirmation hearing for U.S. Supreme Court nominee judge Brett Kavanaugh on Capitol Hill in Washington, U.S., September 4, 2018. REUTERS/Chris Wattie CHRIS WATTIE REUTERS What senior White House official wrote the New York Time op-ed Mike Pence (FILES) In this file photo taken on June 20, 2018 US Vice President Mike Pence speaks as US President Donald Trump looks on before signing an executive order on immigration in the Oval Office of the White House in Washington, DC. - A spokesman for Mike Pence on September 6, 2018 denied the US vice president might be the official who wrote a scathing, unsigned op-ed piece in the New York Times about President Donald Trump. On the internet, the focus on Pence as the possible author apparently stemmed from the use of the obscure word 'lodestar' in the column. Pence is said to have used that term in several speeches in the past.But Pence spokesman Jarrod Agen insisted the vice president did not write the piece, which said Trump's own staff sees him as a danger to the nation who needs to be protected from his own erratic impulses. (Photo by Mandel Ngan / AFP)MANDEL NGAN/AFP/Getty Images MANDEL NGAN AFP/Getty Images What senior White House official wrote the New York Time op-ed Ivanka Trump (FILES) In this file photo taken on August 07, 2018 US President's Special Advisor and daughter Ivanka Trump attends a dinner with the US president and business leaders in Bedminster, New Jersey. - Ivanka Trump, President Donald Trump's daughter and a White House adviser, explicitly condemned "white supremacy, racism and neo-nazism" late Saturday, August 11, 2018, in a manner her father seems reluctant to do. The tweets come on the anniversary of deadly unrest triggered by a white supremacist rally in Charlottesville, Virginia. A similar far-right rally is scheduled for Sunday outside the White House. (Photo by Brendan SMIALOWSKI / AFP)BRENDAN SMIALOWSKI/AFP/Getty Images BRENDAN SMIALOWSKI AFP/Getty Images

“This is a historic moment, it shows that there’s room for all of us at the table,” one of Ms James’s supporters Michelle Gilliam told the Associated Press.