San Diego's original railroad outlet to the East was via the Atchison, Topeka & Santa Fe; during the "railroad wars" of the 1880s a locally chartered company, the California Southern, constructed a line from San Diego north through Temecula Canyon to San Bernardino, where it was met by Santa Fe crews constructing a line over Cajon Pass west from Barstow. The first through train to the East would depart San Diego on November 16, 1885.
However, the line through Temecula proved untenable. The canyon was subject to severe flash floods; indeed, even before the link to the Santa Fe had been completed the California Southern had been shut down for a nine month period due to flood damage. After the Santa Fe had secured entrance to Los Angeles by their purchase of the Los Angeles & San Gabriel Valley railroad in early 1887, a branch was constructed southward from Los Angeles along the coast to San Diego and the line through Temecula was abandoned.
But San Diego backers did not easily give up on their hopes of a direct outlet to the East. If building to the north through Temecula had proved impractical, what about the south? And so the San Diego & Arizona Railway was born. Some engineers of its day referred to it as "The Impossible Railroad" due to the logistic challenges involved. But the road was built south through Mexico and eastward to a connection with the Southern Pacific at Calexico; following financial troubles in the Great Depression it was reorganized as the San Diego & Arizona Eastern under control of the Southern Pacific.