With federal funds at risk of expiring under an agreement forged by the former Patrick administration, the Obama administration has approved a five-year, $52.5 billion Medicaid waiver deal for Massachusetts.

The waiver deal was announced Friday afternoon by Gov. Charlie Baker's administration, which said the arrangement would facilitate a $1.8 billion effort to transition toward accountable care organization (ACO) models of care and investments in behavioral health and long-term care services. An ACO pilot program could launch in December.

The administration signaled that the waiver, which is effective on July 1, 2017, would spare the state from losing $1 billion a year in federal funds. The deal also sustains $6 billion of safety net care payments over five years to hospitals that serve the uninsured and for subsidies to assist those enrolled in Health Connector plans. The number of hospitals eligible for reimbursements for "uncompensated care" expands to 15 from seven, under the deal.

The Centers for Medicare and Medicaid Services approved the waiver. Many states have Medicaid waivers with the federal government, which sanction state efforts to stray from the basic parameters of the state-federal partnership governing the massive health insurance programs. The MassHealth program serves 1.9 million residents.

In statements, Baker said the waiver represented a "major step toward creating a sustainable MassHealth system for the people of the Commonwealth," and federal Health and Human Services Secretary Sylvia Burwell said the waiver was "another step forward in the American health system's shift toward value."

In addition to providing essential coverage for low-income, elderly and disabled individuals, the MassHealth program over the years has been the major cost center in the state budget, often crowding out funds for other programs.

Tom Barker, a former general counsel at the federal human services office, said he believes it's the first waiver to sanction such an aggressive shift toward a new payment model that rewards providers based on care quality and outcomes for patients.

"I don't think any state has gone this far," said Barker, who worked on Massachusetts waivers negotiated between former Gov. Mitt Romney and former Health and Human Services Secretary Tommy Thompson and Gov. Patrick and former HHS chief Mike Leavitt.

From the federal government's perspective, the most important aspect in any waiver talks with states is "budget neutrality," according to Barker, or ensuring that medical expenses do not exceed what they would have been in the absence of a waiver.

Massachusetts has the highest rate of insured residents in the United States, according to the Baker administration. Despite a 2006 law mandating insurance coverage, more than 2 percent of residents remain uninsured. According to the administration, a goal of the waiver is to "maintain near-universal health care insurance coverage."