Torres was born on 28 December 1852, on the Feast of the Holy Innocents, in Santa Cruz de Iguña, Cantabria, Spain. The family resided for the most part in Bilbao, where Leonardo's father worked as a railway engineer, although they also spent long periods in his mother's family home in the Cantabria's mountain region. In Bilbao he studied to enter an advanced high school program, and later spent two years in Paris to complete his studies. In 1870, his father was transferred, bringing his family to Madrid. The same year, Torres began his higher studies in the Official School of the Road Engineers' Corps. He temporarily suspended his studies in 1873 to volunteer for the defense of Bilbao, which had been surrounded by Carlist troops during the Third Carlist War. Returning to Madrid, he completed his studies in 1876, fourth in his graduating class.