The appointment of Ms. Underwood capped a chapter in the staggering and sordid fall from grace of Mr. Schneiderman, a once-promising Democratic official, often hailed as a liberal bulwark against the conservative policies of President Trump, his frequent foil. On May 7, however, that groomed image collapsed after The New Yorker published an article with allegations that Mr. Schneiderman abused alcohol and drugs and choked and slapped four female romantic partners. He resigned within hours, and Ms. Underwood was soon installed, per a succession plan signed in March by Mr. Schneiderman.

Ms. Underwood’s confirmation comes as New York Democrats and Republicans are preparing to meet on Wednesday for their state conventions, and are expected to nominate candidates to succeed her. On the Democratic side, three women are seeking the job: New York City public advocate Letitia James; Leecia R. Eve, a former Clinton administration official, and Zephyr Teachout, a law professor and 2014 candidate for governor. Republicans have three men in the running: Manny Alicandro, a corporate lawyer who has previously worked for JPMorgan Chase; Keith Wofford, a Manhattan lawyer who declared his candidacy on Tuesday, and Thomas E. Humbach, the county attorney in Rockland County.

Gov. Andrew M. Cuomo, a second-term Democrat facing his own primary challenge from the actress Cynthia Nixon, waded into the attorney general’s race shortly after calling for Mr. Schneiderman’s resignation, saying he would conduct his own interviews with candidates. And on Tuesday, Mr. Cuomo endorsed Ms. James for election, calling her “a talented lawyer and a powerful advocate.”

The legislature’s actual action — required by the state constitution — was preordained and almost unanimous, but was accompanied by repeated testimonies in praise of Ms. Underwood, who had been serving as solicitor general before her elevation to New York’s top law enforcement position. In remarks in front of the legislative panel last week, Ms. Underwood cited an impressive résumé, including 20 appearances before the United States Supreme Court, a stint as a clerk for Thurgood Marshall and work in the Manhattan and Brooklyn district attorneys’ offices.

And on Tuesday, lawmakers again called Ms. Underwood supremely qualified for the job. “She’s competent, she’s capable, she has a stellar record,” said State Senator John J. Flanagan, the Long Island Republican who leads the Senate.