Virginia Gov. Ralph Northam, center, reacts after signing the state budget bills that include Medicaid expansion during a ceremony Thursday, June 7, 2018, at the state Capitol in Richmond. (Bob Brown/AP)

On the Capitol steps where he was sworn in five months earlier, Gov. Ralph Northam signed a state budget bill Thursday that gives 400,000 low-income Virginians access to government health insurance.

With his signature, Northam (D) brought a Medicaid battle that raged for four years under his predecessor to an upbeat, bipartisan close. Immediately afterward, he rewarded two senators who had been crucial to the bill’s passage — Democrat Richard L. Saslaw (Fairfax County) and Republican Emmett W. Hanger (Augusta) — with ceremonial pens used to sign the bill.

“We showed Virginia and the world that chaos and partisan warfare may dominate Washington, but here in Richmond, we still work together to do the right thing for our people, not our political party,” Northam told hundreds of activists and about 30 legislators at the ceremony.

Expansion takes effect Jan. 1.

Yet there were signs that the politics of “Obamacare” expansion remained fraught for Republicans. Of the 23 Republicans who supported expansion between the House and Senate, only three attended — Hanger and Dels. Christopher K. Peace (Hanover) and Riley E. Ingram (Hopewell).

That left Northam with a couple of leftover thank-you pens. He intends to give one to House Speaker Kirk Cox (Colonial Heights) and another to Appropriations Chairman S. Chris Jones (Suffolk), key House GOP allies who did not attend.

Cox, who the day before watched President Trump sign a veterans health bill at the White House, released a statement applauding the budget as a way to “reform” Medicaid. He also touted a “taxpayer safety switch” that would nix expansion if Washington does not make good on its promise to pay most of the cost.

Under the Affordable Care Act passed in 2010, Washington allows states to open their Medicaid rolls to people with incomes up to 138 percent of the federal poverty level, which is $16,750 a year for an individual and $28,700 for a family of three. The federal government pledged to pay at least 90 percent of the cost, which in Virginia would amount to about $2 billion a year.

Thirty-two states plus the District took Washington up on the offer. But Virginia, whose existing Medicaid program is one of the country’s leanest, resisted for four years despite the urging of Gov. Terry McAuliffe (D).

Under the state’s current program, a disabled individual can make no more than $9,700 a year. The cutoff for a family of three is $6,900. Able-bodied, childless adults are not eligible, no matter how poor. Opponents said they feared that Washington would renege on its funding promise, sticking Virginia with the tab.

Opposition in the House softened after Democrats nearly won control of the chamber in November. Cox, seeking to rebrand Republicans as pragmatic problem-solvers, backed expansion with work requirements, co-pays and other conservative strings attached.

There was no immediate shift in the GOP-led Senate, which did not face voters last year. But in the end, four Republicans — Hanger, Frank Wagner (Virginia Beach), A. Benton Chafin Jr. (Russell) and Jill Holtzman Vogel (Fauquier) teamed up with Democrats last week to pass it.

Earlier Thursday, Northam was on Capitol Hill to meet with the Virginia congressional delegation. Afterward, he told reporters that he expected the Trump administration to approve the state’s request for Medicaid expansion with requirements that recipients seek employment — conditions that were part of the Democratic compromise with Republicans in Richmond.

Sen. Tim Kaine (D), who was at the meeting with Northam and the delegation, dismissed Republican concerns that Medicaid expansion was too costly for the state in the long run.

“When I hear people talk only about the pennies and not about the people, it makes me mad,” he said, noting that Virginia is 12th in per capita income. “We can deal with the budget issues, but the people matter more than the pennies on this.”

Medicaid expansion was the most high-profile provision of the $115 billion, two-year spending plan. The budget provides Metro with its first-ever source of dedicated funding, plows more money into the state’s two primary reserve funds, workforce credentialing programs and the Port of Virginia, and gives raises to teachers, sheriff’s deputies, and state employees.

Robert McCartney contributed to this report.