PRESTON COUNTY — An underground coal mine fire burns beneath a sprawling hillside in West Virginia, the pale, acrid smoke rising from gashes in the scarred, muddy earth only a stone's throw from some houses.

The fire, which may have started with arson, lightning or a forest fire, smoldered for several years before bursting into flames last July in rural Preston County. The growing blaze moved the mine to the top of a list of thousands of problem decades-old coal sites in West Virginia awaiting cleanup and vying for limited federal funds.

State officials say $4.5 billion worth of work remains at more than 3,300 sites abandoned by coal companies before 1977, when Congress passed a law establishing a national fund for old cleanups. That program was part of an effort to heal the state from the ravages of an industry that once dominated its economy but has fallen on hard times.

“West Virginia is right at the top for needs,” said Chuck Williams, head of Alabama’s efforts and past president of the National Association of Abandoned Mine Lands Programs. He said Pennsylvania, Kentucky and West Virginia — all states with a mining history that extends back two centuries — account for the lion's share of unfinished work among the 28 states and Indian tribes in the program.

Despite being one of the most affected, federal officials have only one-third of West Virginia’s proposed cleanup costs on their $7 billion national list of high-priority work. The sites include old mines that leak acidic water into streams and kill wildlife and dangerous holes that attract children. Tunnels and caverns beneath homes also need to be shored up and new water lines are needed where wells are polluted.

“Our program exists to abate health and safety hazards,” said Rob Rice, chief of the West Virginia Office of Abandoned Mine Lands and Reclamation, which is handling the mine fire. “We have so much need. It's frustrating for us.”

Environmental improvements are a secondary but major benefit, he said.

“This whole area has been extensively mined,” said Jonathan Knight, riding recently through the exurbs east of Morgantown. A planner for the state office, he said housing developments have been built above old mines that many homeowners don't even know about.

The state will get $23.3 million from the federal reclamation fund this year, which is replenished by fees on mining companies. The mines pay 12 cents per ton of underground coal mined and 28 cents per ton from surface mining, but the funding has dropped the past three years with a downturn in coal production.

It will cost about $1 billion just to extinguish all of West Virginia’s 43 fires in abandoned mines, according to the state office. They could have been caused by forest fires, arson, lightning strikes or even old underground explosions that never went completely out.

About $5 million will be spent to extinguish the Preston County fire, smoldering a stone's throw from houses in a mostly rural area near the hamlet of Newburg. In October, the office spent

$209,400 to cut trees and plug holes feeding the fire with oxygen.

The state office, with about 50 staff, is paid from the federal Abandoned Mine Reclamation Fund along with the contractors it hires. Together they close mine portals, extinguish fires, support collapsing hillsides and sinking houses, and treat acidic water leaking out along with dissolved metals. The need for drainage work won't end for centuries. The grants also fund water lines to replace polluted wells.

“There's more water within mine pools in West Virginia than there is in the lakes of West Virginia,” Rice said. “More than 2,500 miles of streams are severely degraded because of mine drainage in West Virginia.”

The state program has brought several back to life with new treatment systems.

The federal program is scheduled by law to expire in 2021, leaving behind about $2.5 billion in a trust fund expected to pay for any ongoing work needed by 25 states and three Indian tribes to address problems from pre-1977 abandoned coal mines.

West Virginia has set aside about $55 million of its grant money received already for continuing water treatment funded by the interest.

The federal program has collected more than $10.5 billion in fees from coal production and distributed more than $8 billion in grants to states and tribes, according to the federal Office of Surface Mining Reclamation and Enforcement. It will provide nearly $181 million in fiscal 2017.

“We continue to discover threats from left-behind mine pits, dangerous highwalls, acid mine drainage that pollutes our water supplies, and hazardous mine openings,” federal director Joe Pizarchik said earlier this year. An Obama administration appointee, he resigned effective last week.

Pollution and lurking underground dangers from mining since 1977 fall into a different category because the federal government made them the responsibility of the companies. They were required to post bonds before opening mines, with the state taking over if they default.