The exit on the American side was hidden by hundreds of sandbags, the authorities said. An offshoot of the main tunnel was also discovered, they added, running 3,529 feet into United States territory but with no opening to the surface.

Image Tracks laid in the nearly mile-long tunnel beneath the United States-Mexico border. Credit... U.S. Customs and Border Protection Agency

The American authorities said that no arrests had been made in relation to the discovery and that no drugs had been found inside the tunnel. The border area has been a stronghold of the Sinaloa Cartel of Mexico, whose leader, Joaquín Guzmán Loera, known as El Chapo, was sentenced to life in prison in July.

In 2015, Mr. Guzmán staged a stunning escape from prison in Mexico, when he vanished from his cell in full view of a video camera through a tunnel that was more than 600 feet longer than the one announced on Wednesday. That tunnel was one of the longest ever built by the cartel, though it did not cross the border.

Guards later discovered a small hole in the floor of his shower that led to a nearly mile-long tunnel 30 feet underground. The shaft was equipped with lighting, ventilation and a motorcycle on rails. Some engineers estimated that it had taken more than a year and at least $1 million to build.

Authorities have been trying for decades to find and cut off the sophisticated cross-border tunnels, many of which include lighting and ventilation systems and have been used by the Sinaloa cartel to move drugs quickly.

In 2018, another cross-border tunnel was discovered in Jacumba, about 55 miles east of San Diego, with a similar rail system and solar-powered lighting.

After the discovery of the latest tunnel the United States border agency said that the Mexican authorities had identified the opening on the southern side and that American investigators had then mapped the entire construction.