A negotiated agreement ends a three-year conflict between North Carolina and South Carolina over the Catawba and Yadkin rivers.

Two southern states have reached an out-of-court agreement on using water from shared rivers, Bloomberg reports.

South Carolina Attorney General Henry McMaster announced the settlement with North Carolina over the Catawba River, which keeps the dispute out of the U.S. Supreme Court.

Although the current dispute has ended, the agreement does leave the door open for future lawsuits, however, if water use or water demand change significantly from the conditions under which this deal was negotiated—including drought.

Named by American Rivers as the most endangered river in the United States in 2008, the 300-mile Catawba River starts in the Blue Ridge Mountains of North Carolina and turns into the Wateree River in South Carolina, eventually emptying into the Atlantic Ocean. It serves as a 10-mile natural border for the Carolinas.

The dispute centers on water diversions in North Carolina that divert millions of gallons each day out of the Catawba Basin, which is used by more than 30 cities and 17 counties for industry and drinking. Over one million people depend on the river for drinking water, while the energy and manufacturing industry—which utilize the river for power generation and cooling—employ thousands. Tens of millions of dollars are generated by several coal, nuclear, and hydroelectric power plants along the river.

Although the current dispute has ended, the agreement does leave the door open for future lawsuits, if water use or water demand change significantly from the conditions under which this deal was negotiated—including drought.

Though the deal does not set limits on water withdrawals, it does lay out a process for assessing any future water transfers and sets standards for reducing water use during droughts. Other components of the deal include updating a basin water supply study every 10 years.

“We are pleased to report that this settlement addresses the fundamental question of [inter-basin transfers], raised by the litigation, in a fair manner for everyone,” McMaster said in a press release. “Through the terms of the settlement, both North and South Carolina will be close neighbors rather than a plaintiff and defendant in a lawsuit.”

The case has cost South Carolina over $3 million since McMaster first took legal action in 2007, when North Carolina officials approved inter-basin transfers of an additional 10 million gallons per day for two suburbs of Charlotte, the region’s fast-growing urban hub. The city was already withdrawing 33 million gallons per day, in addition to other transfers by industry in the area totaling 40 million gallons per day.

Before the current agreement, North Carolina’s Environmental Management Commission was able to do approve the transfers without notifying downstream users and without doing an assessment of the environmental effects. Now, South Carolina—which passed a law this year requiring permits for large water withdrawals—will be notified of any transfer proposed by its upstream neighbor, and an environmental impact statement must then be prepared.

When the Supreme Court began hearing the case in 2009, it ruled that third parties Duke Energy—an energy company operating 11 hydroelectric dams in the Catawba Basin—and the Catawba River Water Supply Project—a basin water user—could join the lawsuit, but the city of Charlotte could not.

The deal, signed last week by all parties, was based on one written by Duke Energy in its application for dam relicensing with the Federal Energy Regulatory Commission.

Source: Bloomberg, South Carolina Attorney General’s Office

Read more on Circle of Blue:

Correction: An earlier version of this story said that Alcoa was transferring water out of the Yadkin River basin. That is incorrect. The company is in a separate dispute with the state of North Carolina over state permits needed for federal relicensing of its dams on the Yadkin River.