RICHMOND, Va. (AP) — Virginia's governor is set to sign legislation in coming days expanding Medicaid after the state's Republican-controlled General Assembly ignored warnings from the White House against expanding the health care program for the poor.

The state Senate voted Wednesday in favor of a state budget that expands Medicaid. The House, which had had previously endorsed expansion, gave its final approval shortly afterward. Several Republicans in both chambers joined with Democrats to approve the measure.

Ironically, Republican lawmakers said it was the Trump administration's embrace of work requirements for low-income people on Medicaid that help get the measured passed after years of partisan battle.

Expanding Medicaid was a key provision of then-President Barack Obama's health care overhaul, which President Donald Trump has vigorously sought to negate. White House officials, including budget director Mick Mulvaney, have urged Virginia lawmakers this year not to expand Medicaid. Trump's recent budget proposal calls for repealing Medicaid expansion and Mulvaney said the administration is "committed to addressing the unsustainable growth" of the program.

But Virginia GOP Speaker Kick Cox said the Trump administration's openness to conservative reforms, including work requirements, "was probably the biggest key" in getting Republican support for Medicaid expansion this year.

And a failure by the GOP-led Congress to repeal and replace the health law helped spur several of Virginia's Republican state legislators to flip positions.

"There's always talk of repealing Obamacare, that did not happen," Cox said.

Democratic Gov. Ralph Northam is expected to sign the measure, and the roughly 400,000 newly eligible low-income Virginias will begin enrolling in Medicaid at the start of next year.

Senate passage came by a 23-17 vote with four Republicans joining Democrats for passage. The House quickly followed about an hour later with a lopsided 67-31 final endorsement.

Wednesday's voting marked the end of a more than four-year battle over whether Virginia should expand the publicly funded health care program for the poor. A fight over Medicaid expansion led to a standoff over the state budget in 2014 and again this year.

Virginia Democrats have argued the state should not pass up the roughly $2 billion in extra federal funding the program would bring to the state. Republicans had previously been near unified in blocking past expansion efforts, saying the long-term costs were unsustainable.

Those arguments were again replayed in the final hours before Virginia's partisan battle was finally ended.

Sen. Ben Chafin, a Republican lawmaker from Virginia's economically depressed southwest coal country, announced his support for expansion on the Senate floor. He said his rural area needed expansion to help bolster its hospitals and provide care for constituents in need.

"I came to the conclusion that no just wasn't the answer anymore," Chafin said.

But several Republican senators remained strongly opposed, saying Medicaid costs would eventually overwhelm the rest of the state's budget needs for schools and public safety.

"It is a ticking time bomb," said GOP Sen. Bill Stanley.

Democrats campaigned heavily on expanding Medicaid last year and some House Republicans were eager to take the issue off the table before next year's election, when both House and Senate seats are up.

Virginia saw its state legislature reshaped by an anti-Trump wave as Democrats made unexpectedly large gains in the state House.

A tally from the Kaiser Family Foundation shows Virginia will become the 33rd state to approve Medicaid expansion.