If it hadn’t been for the Mexican Cession of 1848, much of the southwestern United States—California, Arizona, New Mexico, and parts of Utah, Nevada, and Colorado—would still belong to Mexico. But you probably already knew that, thanks to your U.S. History lessons in elementary school.

What doesn’t typically appear in history books, however, is the town the United States returned to Mexico. And it wasn’t ceded centuries ago—this happened in the 1970s.

The Rio Grande, as most people know, is the physical border between Mexico and the United States, and has been since 1845. In 1906, the Rio Grande Land and Irrigation Company feared that a new S-shaped curve in the river would result in flooding and property damage, so they illegally diverted a portion of it. But solving that problem created a new one: 413 acres of U.S. land were now suddenly located south of the river. Although it was decided that this small parcel of land, known as the Horcón Tract, would legally remain part of Texas, it was administered by Mexico.

In 1929, the city of Rio Rico was formed on the tract to take advantage of the boundary confusion. Though Prohibition was in full swing in the U.S., visitors to the little town could drink and gamble freely because the jurisdiction was rather unsettled.

The boundary remained ambiguous until 1967, when James Hill, Jr., a geography professor at Arizona State, came across the issue while studying old geological survey maps. The United States Boundary Commission and the State Department became interested, and in November 1970, the U.S. officially ceded the tract of land to Mexico.

Two years later, Homero Cantu Trevino of Rio Rico filed suit to prevent the U.S. from deporting him from Texas to Mexico. Trevino argued that because he was born in Rio Rico in 1935, he was legally a citizen of the U.S. An appeals court eventually agreed with him, and it was ruled [PDF] that all residents born in the city before 1972 could retain U.S. citizenship, which resulted in a huge decrease in Rio Rico’s population as residents moved elsewhere in the United States.

It’s not the first time something like this has happened, by the way. The Rio Grande has shifted quite a bit in 1852, often due to flooding. By 1873, the river had moved, changing 700 acres of Mexican land referred to as “Chamizal” into U.S. territory. The conflict over who owned the land increased tensions between the U.S. and Mexico for a century. In fact, when President William Howard Taft met with Mexican president Porfirio Diaz in the then-neutral Chamizal to discuss the issue, they were very nearly assassinated—a security detail disarmed a man with a concealed pistol just feet away from the leaders.

Eventually, in 1963, the U.S. announced a border agreement that would return most of Chamizal back to Mexico. The two countries also agreed to jointly finance the construction of a trench that would keep the river on a set path—and hopefully avoid inciting border disputes in the future.