ALBANY — The state's solicitor general, Barbara D. Underwood, was appointed as attorney general during a joint legislative hearing Tuesday that came two weeks after scandal-scarred Eric Schneiderman abruptly resigned in the wake of allegations he abused women.

Underwood, who had been serving as acting attorney general, is the first woman to serve as New York's attorney general and will hold the position through the end of the year.

Members of the Senate and Assembly gathered in the Assembly's chamber and approved Underwood's appointment in a near-unanimous vote, with several lawmakers taking time to publicly praise her record.

"I've served in many roles in government throughout my career. But I believe this job — at this moment in history – is the most important job I have ever had," Underwood told reporters after her confirmation.

The state Constitution requires the Legislature to cast a joint ballot to fill the vacancy in the statewide office. Schneiderman resigned May 8, one day after the publication of an article in The New Yorker in which four women alleged he used physical violence against them.

A bicameral, bipartisan vetting committee headed by Democratic Assemblyman Joe Lentol of Brooklyn interviewed 12 candidates last week, but legislative leaders overwhelmingly supported keeping Underwood in the position through the rest of the year.

Although Schneiderman's resignation brought wide interest from potential candidates for the legislative appointment, many of them subsequently backed off amid criticism that the selection would be viewed as a backroom deal that could complicate the quest for a full term. New York City Public Advocate Tish James, currently seen as the front-runner for the Democratic nomination to the post, took herself out of the running before the vetting committee met last week.

Assembly Speaker Carl Heastie has disputed the notion that there were talks of a political arrangement and he said the decision was primarily based on the timing of the state Democratic and Republican conventions, which begin Wednesday. The nominations of attorney general candidates for November's general election are scheduled to take place at those events.

"We think this fair. We think whoever the next attorney general, there will be enough of a transition period," Heastie said on Tuesday morning.

Many lawmakers noted that keeping Underwood on the job — and she made it clear she will not seek election to the office — would bring stability to the agency after the tumult of Schneiderman's shocking fall.

"The office became open under very painful circumstances, and so having an individual who could have continuity with the office and personnel, was a very important criteria," said Sen. Kenneth P. LaValle, R-Long Island, who served on the vetting committee.

Only Brooklyn Assemblyman Charles Barron voted "no," citing concerns with the process. Others approved Underwood's appointment, but also plugged legislation that would enable vacancies for state attorney general or comptroller to be filled through a special election rather than by legislative appointment.