The Supreme Court said Thursday that a large swath of eastern Oklahoma remains an American Indian reservation, a decision with potential implications for nearly 2 million residents and one of the most significant victories for tribal rights in years.

The land at issue contains much of Tulsa, the state’s second-largest city. The question for the court was whether Congress officially eliminated the Muscogee (Creek) Nation reservation when Oklahoma became a state in 1907.

In a 5-to-4 decision invoking the country’s long history of mistreating Native Americans, the court said “we hold the government to its word” and the land Congress promised to the Creek Nation is still Indian land.

“If Congress wishes to withdraw its promises, it must say so. Unlawful acts, performed long enough and with sufficient vigor, are never enough to amend the law,” wrote Justice Neil M. Gorsuch, who was joined by the court’s liberal justices.

“To hold otherwise would be to elevate the most brazen and longstanding injustices over the law,” Gorsuch said, “both rewarding wrong and failing those in the right.”

The dissent, led by Chief Justice John G. Roberts Jr., warned of significant upheaval in the criminal justice system, and in other areas of government such as taxing and zoning. But state and tribal leaders downplayed those concerns and said they are negotiating an agreement to address jurisdictional issues.

Most directly, the ruling means that federal officers, not state authorities, have the power to prosecute tribal members for major crimes committed in the defined area. Less certain is how the decision affects the authority of state and city leaders when it comes to imposing taxes, zoning laws and other regulations.

Oklahoma Attorney General Mike Hunter and leaders of five tribal groups issued a joint statement after the ruling indicating they have made “substantial progress toward an agreement” to submit to Congress and the Justice Department that would put in place a “framework of shared jurisdiction.”

“We have a shared commitment to maintaining public safety and long-term economic prosperity for the Nations and Oklahoma,” according to the statement from Hunter and the Creek, Cherokee, Chickasaw, Choctaw and Seminole nations.

Lawmakers in Washington would have to pass legislation, for instance, for state officials to continue prosecuting crimes involving tribal members in the area affected by the Supreme Court’s ruling.

The case was brought by Jimcy McGirt, a member of the Creek Nation who was convicted in state court of molesting a child. Because the crime occurred on the land in question, McGirt said that state courts had no jurisdiction and that the federal government would have to prosecute. The court’s ruling tosses McGirt’s state conviction and means he must be tried in federal court.

Oklahoma and the federal government contended that laws passed between 1890 and 1907 gave the state jurisdiction over the land. The state said that there are thousands of similar cases and that a ruling in favor of McGirt would not only throw the criminal-justice system in turmoil but also disrupt taxing powers and other municipal jurisdictions.

In his dissent Thursday, Roberts agreed, writing that the state’s ability to prosecute crimes “will be hobbled and decades of past convictions could well be thrown out.”

“On top of that, the Court has profoundly destabilized the governance of eastern Oklahoma. The decision today creates significant uncertainty for the State’s continuing authority over any area that touches Indian affairs,” wrote Roberts, who was joined by Justices Samuel A. Alito Jr., Brett M. Kavanaugh and Clarence Thomas.

The ruling specifically addresses the Creek Nation. But the state said as much as half of its land and roughly 1.8 million residents could end up living within Indian country, abutting Kansas, Arkansas and Texas. Four other tribes have reservations in eastern Oklahoma, all created by treaties during the same time period.

But the majority insisted the opinion is a narrow one and that “each tribe’s treaties must be considered on their own terms.” Gorsuch pointed out that many defendants prosecuted by the state may still choose to finish their sentences rather than risk proceeding in federal court where penalties are often steeper than in state court.

“We do not pretend to foretell the future and we proceed well aware of the potential for cost and conflict around jurisdictional boundaries, especially ones that have gone unappreciated for so long,” Gorsuch wrote. “But it is unclear why pessimism should rule the day. With the passage of time, Oklahoma and its Tribes have proven they can work successfully together as partners.”

Attorneys for the Creek Nation and McGirt recalled the country’s broken promises and poor treatment of Native Americans. In the 1830s, members of the Creek Nation and four other tribal groups were forcibly marched by the U.S. Army from Alabama and Georgia to the land in eastern Oklahoma which they were promised in exchange for leaving.

Ian H. Gershengorn, McGirt’s attorney, said in a statement that the court’s ruling reaffirmed that “when the United States makes promises, the courts will keep those promises.”

“Congress persuaded the Creek Nation to walk the Trail of Tears with promises of a reservation — and the Court today correctly recognized that this reservation endures.”

Riyaz A. Kanji, the Creek Nation’s lawyer, said he does not expect the ruling to result in major upheaval because of long-standing cooperation between tribal and state leaders.

“Life is not going to change dramatically within the reservation, but it will allow the Nation to continue exercising governmental authority and engaging in governmental programs that benefit Indians and non-Indians” such as health-care services, he said.

The court also resolved a second similar case that was argued last term, but not decided until Thursday. In that case, Gorsuch had recused himself because he had participated in it as a judge on the appeals court in Colorado. Apparently deadlocked, the justices took the new case and on Thursday invalidated the state convictions of both McGirt and Patrick Murphy, a Creek Indian convicted and sentenced to death in the murder of a fellow Creek Nation member in 1999.

State and tribal leaders said in their joint statement that they are “committed to ensuring that Jimcy McGirt, Patrick Murphy, and all other offenders face justice for the crimes for which they are accused.”

In its ruling Thursday, the majority held that only Congress, not the court, has the authority to modify treaty agreements and change reservation boundaries.

“The opinion is a strong, clear and important statement that limits the court’s role in diminishing tribal rights,” said Sarah Krakoff, a professor of American Indian law at the University of Colorado’s law school.

The decision, she said, “reflects the better aspects of what is otherwise an incredibly fraught and negative history for tribes in this country.”

The cases are McGirt v. Oklahoma and Sharp v. Murphy.

Robert Barnes contributed to this report.