OKLAHOMA CITY (AP) – Oklahoma and two Native American tribes have reached a settlement to end a water rights and tribal sovereignty dispute stemming back to the 19th century, according to negotiators for both sides.

Tribal leaders are expected to join the governor and other state officials as a news conference Thursday to detail the agreement, which was announced late Wednesday.

The Chickasaw and Choctaw nations have long accused Oklahoma of not abiding by the 1830 Treaty of Dancing Rabbit Creek, which gave the tribes authority over water in their jurisdiction. The state argued that the tribes were ignoring an 1866 pact in which they gave up certain rights after backing the Confederates in the Civil War.

The current fight started in 2011, when Oklahoma City – which receives water from southeast Oklahoma reservoirs in both tribes’ territories – sought rights to more water from one of those reservoirs, Sardis Lake.

The tribes filed a lawsuit alleging that the Oklahoma Water Resources Board had no right to consider an offer to use water from traditional Native American homeland. Oklahoma later countersued, saying it wanted a court to resolve where the tribes’ rights begin and end.

Negotiators, including former U.S. District Judge Michael Burrage, told The Associated Press ahead of a formal announcement scheduled for Thursday that an agreement had been reached.

Under the settlement, Oklahoma would continue to manage the state’s natural water supply but acknowledge tribal sovereignty and meet the tribes’ conservation guidelines, negotiators said. The deal also guarantees Oklahoma City’s long-term access to Sardis Lake.

The agreement could be signed as early as Thursday by U.S. District Judge Lee West. Congressional approval is also required.

The dispute over Sardis Lake, which was built by the U.S. Army Corp of Engineers, is one of several that have focused on southeastern Oklahoma’s abundant water resources. The region’s Atoka pipeline has transported water to Oklahoma City and surrounding areas in central Oklahoma for about 50 years.

In 2013, the U.S. Supreme Court unanimously ruled in Oklahoma’s favor in a lawsuit filed in 2007 by the Tarrant Regional Water District in North Texas that sought access to southeastern Oklahoma tributaries of the Red River that separates the two states.

In the Sardis Lake case, the tribes initially sought, among other things, an injunction against the Oklahoma Water Resources Board and the Oklahoma Water Conservation Storage Commission.

The state responded with its own lawsuit in February 2012 asking the Oklahoma Supreme Court to decide what rights the two tribes actually have to water in the region. Authorized by the Water Resources Board, it sought a comprehensive adjudication of tribal water rights in the Kiamichi River and other stream basins.

The state’s lawsuit was eventually transferred to federal court and formal mediation began on July 2012.

It took five years to settle the Sardis Lake dispute, but other water fights, especially in the drought-prone West, have dragged on far longer.

In 2010, officials in New Mexico settled a 1966 lawsuit involving more than 2,500 defendants in a case involving four Native American pueblos and non-Native American residents in northern Santa Fe County.