Letitia James, the New York City public advocate, declared her candidacy for the Democratic nomination for attorney general on Wednesday, ending a week filled with rumors and political machinations about whether she would be appointed to the office or run for it, and with which party’s backing.

After the sudden resignation of Eric T. Schneiderman last week, Ms. James’s name immediately surfaced as a candidate to replace him, first as an interim appointment by the state Legislature.

But as newspaper editorial boards urged lawmakers to keep the interim attorney general, Barbara Underwood, who had served for years as state solicitor general, in the job, Ms. James withdrew her name from consideration to fill out the last seven or so months of Mr. Schneiderman’s term.

Instead, Ms. James said she wanted to place her candidacy before voters, saying that she would defend vulnerable communities and take on everything from corruption to crooked businesses, as well as the administration of President Trump.