In a rare instance of Senate Democrats and House Republicans working together, Congress agreed Tuesday to shift funding formerly allocated to presidential conventions to programs focused on pediatric medical research.

The bill, the Gabriella Miller Kids First Research Act, was approved unanimously by the Senate, without a roll call vote, after being championed by Virginia Democrats Sen. Mark R. Warner and Sen. Timothy M. Kaine as well as by Sen. Orrin G. Hatch (R-Utah), a veteran advocate for federal research.

In a statement, Kaine and Warner applauded colleagues for routing more federal dollars to childhood cancer research and for honoring the memory of Miller, a 10-year-old Loudoun County girl who died in October, almost a year after a brain cancer diagnosis.

Kaine and Warner also praised House Majority Leader Eric Cantor (R-Va.), who served as the major advocate for the bill as part of his effort to push Republicans away from fiscal wars and toward family friendly items.

The House passed the bill in December on a vote of 295 to 103, as Miller’s parents watched from the visitors’ gallery. Democrats who opposed it said it deflected attention from broader budget cuts at the National Institutes of Health.

The path to passage in the Senate was difficult, with Democrats wanting to boost cancer research by increasing NIH funding beyond the amount designated in the bill. It moves $126 million, over 10 years, from a fund for political conventions toward the NIH’s Common Fund, which promotes research of cancer and other diseases.

“It’s extremely important that we understand that the NIH is billions of dollars short of being able to maintain the place they’ve had in past years,” said Senate Majority Leader Harry M. Reid (D-Nev.).

But after cloakroom discussions led by Warner, Kaine and Hatch, party leaders put aside their differences.

The vote marks a change in how presidential campaigns are funded. Once the bill is signed, parties will be forced to seek more private donations for their nominating conventions. They will continue to receive federal dollars to pay for security costs with local law enforcement, but in 2012, almost $40 million went to finance other non-security items at the Democratic and Republican conventions.

As the Senate voted, a cheer went up in Cantor’s suite across the Capitol. After a year of tense standoffs and acrimony with Senate Democrats, the vote underscored Cantor’s effort to reshape the House GOP’s agenda, with a focus on lowering the occasionally grand expectations of conservatives and sponsoring legislation that could pass a divided Congress.

Cantor said his goal — with the cancer research measure and other House-passed bills dealing with workplace rules and job-skills training — is to convince middle-class voters that Republicans are willing to govern and offer an alternative set of policies meant to support families instead of just rallying the GOP’s tea-party base.

“We want to deal with issues that are important to people in their own lives, to help them regain their confidence in Washington,” he said.

With Republicans struggling with a reputation for intransigence after last year’s shutdown of the federal government, Cantor is aware that passage of the Miller bill is but one step forward. Still, he is optimistic that in coming months, Republicans can do more with Democrats.

Some House conservatives have criticized Cantor’s initiatives, saying that Republicans should do more to tout their desire to repeal the federal health-care law and balance the federal budget.

“The Republican rank-and-file is much more conservative than the Republican leadership, much more willing to duke it out,” said Rep. Dana Rohrabacher (R-Calif.). “Those of us who elected Eric expected him to be a lot more aggressive than he is right now.”

But, Cantor said, the party can be against the federal health-care law and for a balanced budget while also being “for something,” from workforce training to charter schools.

“I would hesitate to not call job growth or health care really big things,” he said. “We have a lot of disagreement on some of the fiscal policy with Democrats, which means we ought to focus on where we can agree — on the human impact of what we are doing.”

In coming months, Cantor plans to hold votes on bills crafted to win conservative support — an alternative to the Affordable Care Act, for instance — with bills that could win Democratic backing, such as legislation on immigration, an issue that has long divided Republicans.

Paul Kane contributed to this report.