SAN DIEGO — A deep tunnel snaking nearly 600 yards from Mexico under the border and into a San Diego warehouse is one of the most sophisticated underground drug smuggling passageways ever discovered, complete with electricity, ventilation and an electronic rail system, federal authorities said Thursday.

The tunnel, which was shut down Wednesday night after several weeks of surveillance, took about a year to build, the authorities said. Three people were taken into custody, and federal agents seized eight tons of marijuana and 325 pounds of cocaine they said was connected to the investigation.

As security at the border — both at the ports of entry and between them — has heightened in recent years, drug cartels have increasingly sought other avenues, including tunnels, maritime smuggling and ultralight aircraft, to move drugs into the United States. This was the fifth large-scale drug smuggling tunnel discovered in the San Diego area since 2010, the authorities said, and the eighth since 2006, when the Sinaloa drug cartel took firm control of the smuggling corridor along this section of the border.

“These cartels have spent years and tens of millions of dollars trying to create a secret underworld of passages so they can move large quantities of drugs,” said Laura Duffy, the United States attorney for the San Diego region.