Moorefield, WV, is a small town that faced a problem many small towns encounter: How to pay for a new, expensive wastewater treatment system when residents’ wallets are already stretched by high taxes and low salaries.

But the way it solved its problem makes Moorefield unique. The town of 5,000 residents partnered with a company, Pilgrim’s Pride, and two other nearby systems, all of which needed to improve their waste treatment.

Together they built a $40 million treatment system that will reduce total nitrogen loads by 90,000 pounds a year and total phosphorus by 93,000 pounds a year. The system will compost much of its own waste and sell the products, as well as reuse some of its water to save money.

The system prepares to go online this month, after 13 long years in the making. West Virginia environmental officials say it is the first enhanced nutrient removal system in the state. Another is likely coming to Martinsburg in the next few years. Many environmental activists say, it’s long overdue.

“It’s about time that they have a facility that is going to incorporate the waste from Pilgrim’s Pride and is going to clean the water better than in the past,” said Brent Walls, the Upper Potomac’s Riverkeeper.

The new plant comes after a one-two punch of new regulations and continuing problems.

Moorefield had a sewage treatment system that was failing, an old lagoon that was built in a floodplain near the town center. It could not rebuild a plant in that location, and it could not pay to put one elsewhere without significantly raising rates.

Pilgrim’s Pride, which processes poultry at its Moorefield facility, had faced violations at its two plants for, among other things, exceeding the amount of fecal coliform bacteria it discharged into the Potomac River. In the last two decades, the West Virginia Rivers Coalition and the state’s Department of Environmental Protection sued over those violations.

There were also problems at the small plant in Caledonia Heights, a subdivision with its own treatment system that had many illegal hook-ups and failures. The fourth entrant into the Moorefield partnership was the Hardy County Rural Development Authority.

In 2001, town officials and Pilgrim’s Pride began talking about collaborating. Then, in June 2002, West Virginia signed the Chesapeake Bay Water Quality Memorandum of Understanding. That made the state a partner in Bay restoration. A decade later, when the total maximum daily load requirements came down, the water-quality requirements applied to West Virginia as well.

Asked why it took 11 more years to make the plant a reality, Moorefield Public Works Director Lucas Gagnon said the answer is simple: money. Each side had to make the numbers work. And they had to do it in a time of federal and state funding cuts.

Ultimately, the West Virginia State Revolving Loan Program paid for almost half of the project. The rest came from other state and federal programs, including proceeds from the state lottery. Pilgrim’s Pride kicked in $1.5 million; Moorefield put in close to $400,000, according to Carla Hardy, the watershed program coordinator of the West Virginia Conservation Agency.

Pilgrim’s Pride made sacrifices to help the town, Gagnon said. It would have been cheaper and easier for the company to build its own plant. Indeed, the state had to change a law so a private entity could sit on the board of a wastewater plant. But Pilgrim’s Pride wanted to be a good corporate citizen. Many Hardy County residents raise poultry for the company, which is based in Greeley, CO.

“Without Pilgrim’s, our rates would have gone up quite a bit,” Gagnon said.

As it is, the company is taking on 85 percent of the debt in the project, and will be contributing 85 percent of the load. Gagnon said that enables Moorefield to keep its rates at about $36 a month for water and sewer.

Other towns haven’t been so lucky. In Woodstock, just across the state line in Virginia, requirements for a new treatment plant resulted in a $31 million investment. Townspeople saw their monthly bills triple, to an average of $100 per family. Residents of Berryville, VA, are going to see their rates quadruple.

Like Woodstock and Berryville, Moorefield’s new system was long overdue. Near the old plant, the Potomac was clogged with algae blooms, Walls said, even at very low water levels.

“It was unbelievable. It was overpowering, the smell,” Walls said of the old plant. “And when you went farther down the road, you smelled the chicken. That was the difference from one part of town to the other, where the two plants were. It was just very noticeable.”

The new Moorefield Regional Wastewater Treatment Plant is about two miles from downtown, close to the South Branch of the Potomac River.

It will work like this: Pilgrim’s Pride will run its waste through a pre-treatment system, then pump that waste, as well as that of customers in the town, through a pipe. The plant will remove grit and grease and then carry the waste to a five-stage biological treatment process that includes nitrification, denitrification, oxidation, and biological and chemical phosphorus removal. It will also separate sludge from the water. The wastewater will be chlorinated and sent over a cascading system to raise the levels of dissolved oxygen. Then, the chlorine will be removed and the effluent will be discharged into the river, though some of it will come back to the plant to be used again for washing and processing.

The sludge will be put into an aerobic digester and mixed with carbon to make compost, which Gagnon plans to sell as mulch to garden companies.

Gagnon said he’s proud of the facility. He said other towns could learn from the Moorefield example if they’re willing to be creative and patient.

“There were many times, even since I’ve been here, where I thought, ‘this project is dead,’ ” Gagnon said. “There have been lots of highs, and lots of lows. But it’s good to see it finally happen.”