This has been a very good year for Letitia James.

Over the past month, Ms. James, New York’s attorney general, has racked up hard-fought victories over two formidable opponents. First, in mid-February, her office won a staggering $454 million judgment against former President Donald J. Trump in a civil fraud trial stemming from accusations that he had inflated his net worth.

A week later, Ms. James, a Democrat, prevailed again, this time against the National Rifle Association and its longtime leader, Wayne LaPierre, who was found personally liable for more than $5 million in misused funds.

“It took a prosecutor with the mettle to get under the hood,” Nick Suplina, the senior vice president for law and policy with Everytown for Gun Safety, a gun-violence prevention group, said of the N.R.A. case. “And that’s what Attorney General James did.”

The dual victories against figures viewed as villains by her fellow Democrats has, in some quarters, made Ms. James a hero, complete with the kind of résumé-burnishing accomplishments that can presage an ascent to the governor’s mansion or national office. Ms. James, who won a second term handily in 2022, is seemingly reveling in her reputation as an antagonist of right-wing political figures, some of whom have reacted to her public pronouncements with fury.

Ms. James’s other recent targets include neglectful nursing homes, anti-transgender bans and the world’s largest meat producer. But her outspokenness regarding Mr. Trump has underscored the tension between an attorney general’s pledge of impartiality and the political benefits of attacking a deeply unpopular Republican in a state where Democrats dominate.

Delaney Kempner, a spokeswoman for Ms. James, said Saturday that the attorney general had been elected “to take on the biggest threats to our state and to protect its people, and she has done exactly that.”