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