WASHINGTON (Reuters) - The U.S. government and coal companies will be required to pay out healthcare to retired coal miners, guaranteeing benefits to workers even as coal companies face bankruptcy, after Congress on Sunday reached a fiscal spending agreement for 2017.

West Virginia Democrat Sen. Joe Manchin (R), who broke ranks to vote with Republicans for Jeff Sessions to become U.S. Attorney General, looks towards U.S President Donald Trump during a Supreme Court listening session at the White House in Washington, U.S., February 9, 2017. REUTERS/Kevin Lamarque

The provision to secure the United Mine Workers’ healthcare benefits was included in a deal that lawmakers reached late on Sunday for around $1 trillion in federal funding that would avert a government shutdown later this week.

Around 22,600 coal miners and their families were on the brink of losing on April 30 their healthcare benefits, which were at risk of default as the industry struggled, with companies trying to recover from bankruptcies.

“This permanent solution to protect these benefits is a victory for our miners, their families, and their widows,” said Congressman Evan Jenkins, a West Virginia Republican who represents the state’s coal-producing counties.

Members of the UMWA have made several visits to Washington over the last few months to urge lawmakers to protect their benefits, which they say is a government obligation.

President Harry Truman in 1946 brokered the Krug-Lewis agreement, which guaranteed health and pension benefits for coal miners.

Sunday’s agreement did not address a long-term fix for miners’ pension funds, which are also set to be terminated.

Lawmakers from both parties still hope to pass the Miners Protection Act, which would transfer funds from the Abandoned Mine Land fund to the union’s pension plan to prevent its insolvency.

Democratic Senator Joe Manchin of West Virginia has been working with the UMWA and Democratic and Republican lawmakers to pass that bill.

If Congress cannot transfer those funds, the financially-strained $5 billion federal Pension Benefit Guaranty Corp, an agency that backstops failed private-sector pension programs, would be responsible for covering the plans.

Manchin said there is a “sacred bond between worker and country” and that he “is more determined than ever to fulfill our whole obligation and secure retired miners pension benefits as well.”