AUGUSTA, Maine — The Maine House on Wednesday agreed to a compromise measure that would allow the state to expand Medicaid under the federal Affordable Care Act but cut off the expansion after three years.

The measure managed to attract slightly more support than the Medicaid expansion bill attracted in its last go-around in the House, when five Republicans supported the expansion. But the 97-51 tally means Democrats still fell short of the two-thirds threshold they would need to override a near certain veto from Republican Gov. Paul LePage.

The House voted mostly along party lines to agree to the compromise measure crafted by Assistant Senate Republican Leader Roger Katz of Augusta that passed the Senate last week.

Six Republicans joined the House’s Democrats and unenrolled members to support expanding Medicaid. Two House Republicans who supported the expansion in a vote earlier this month — Reps. Sharri MacDonald of Old Orchard Beach and Windol Weaver of York — switched their votes to oppose the measure Wednesday. Three Republicans who opposed the previous Medicaid expansion bill supported the amended measure: Reps. Donald Marean of Hollis, Corey Wilson of Augusta and Ellen Winchenbach of Waldoboro.

The measure would sign Maine up for the expansion under the federal health care law but have Maine withdraw after the three years during which the federal government pays 100 percent of expansion costs unless the Legislature at that time decides otherwise.

The deal would also require the Legislature hire a nonpartisan research group to study the effect of Maine’s Medicaid expansion after the three-year period expires. And Katz proposed allowing the state’s Medicaid program, known as MaineCare, to charge patients the maximum co-payments allowed under federal law as a way to dissuade Medicaid recipients from using the emergency room for care.

Because Maine would spend less in state funds on Medicaid during the first three years of the expansion, and the state Department of Health and Human Services is working on a number of initiatives to reduce Medicaid costs, Katz’s proposal would set aside the savings in a special account that could be used to cover additional Medicaid costs once the federal government’s share of expansion costs drops below 100 percent in 2017.

Rep. Jeff McCabe of Skowhegan, the assistant Democratic leader in the House, said the Senate version is something to celebrate. He called it the result of lawmakers working together.

The bill “has been amended because people in this room on both sides of the aisle have expressed concern, asked questions and shown courage,” he said. “It’s amended so we can get out at any point in time if the federal government does not stay to their word and pay what they say they will pay.”

Rep. Mark Dion, D-Portland, said providing health care for low-income people would result in savings in the criminal justice system because many arrive at Maine prisons with health problems, particularly with mental health. Dion, a former Cumberland County sheriff, cited the support other law enforcement officials have voiced for expanding Medicaid.

“A proper investment at the front end helps to contain the cost of corrections, law enforcement and judiciary at the back end,” Dion said.

Republicans continued to argue that Maine shouldn’t provide health coverage to thousands of nondisabled people while hundreds of people with disabilities are on wait lists for services in their homes and communities.

“My constituents are going to say, ‘We’ve neglected this group of people,’” said Rep. Michael Nadeau, R-Fort Kent.

“What we are doing is increasing access and probably increasing costs and, yes, it will probably help the hospitals, but I’m not sure we’ve done anything for quality,” said Rep. Richard Malaby, R-Hancock.

Since Maine already covers 27 percent of its population with Medicaid, the state doesn’t have as much to gain from expanding the program, said Rep. Wayne Parry, R-Arundel. As a result, today’s lawmakers would be saddling legislators in the future with the costs of an expanded Medicaid program.

“That’s this legislature binding another legislature,” he said. “We need to look into the future also.”

The House vote on the compromise measure came after representatives rejected an amendment proposed by Rep. Deborah Sanderson, R-Chelsea, that would add a $75 million annual price tag to a bill that currently carries no official price tag and promises the state savings over the next three years.

Sanderson’s amendment would require the state provide services to hundreds of people with physical and intellectual disabilities who are currently on waiting lists for those services. Republicans opposed to expanding Medicaid, including Gov. Paul LePage, have frequently pointed to the existing wait lists for services as a reason they can’t support the Medicaid expansion.

The vote to reject Sanderson’s amendment, 88-61, was cast largely along party lines.

“If you don’t put these people as a priority now, they will never be a priority for us,” Sanderson said. “We will continue to subject the neediest of our citizens to abuse, abuse from neglect.”

Democrats agreed Sanderson’s proposal addressed an important issue. But attached to the Medicaid expansion proposal, it’s an attempt to cause the expansion legislation to fail, McCabe said.

“These federal dollars are coming to us specifically for an opportunity,” he said. “We must accept these dollars and we must continue to work together to address this waiting list.”

Expanding the state’s Medicaid program would provide coverage for about 50,000 adults without children who earn up to 133 percent of the federal poverty level, or $20,628 for a two-person household. The expansion would also prevent about 25,000 parents and childless adults from losing their Medicaid coverage starting Jan. 1, 2014.