He was born at Santander where he showed that he was an infant prodigy. At only 15, he studied under Manuel Milà i Fontanals at the University of Barcelona (1871–1872), then proceeded to the central University of Madrid. His academic success was unprecedented; a special law was passed by the Cortes to enable him to become a professor at 22. Three years later, he was elected a member of the Real Academia Española; but he was already well-known throughout Spain.
His first volume, Estudios críticos sobre escritores montañeses (1876), had attracted little notice, and his scholarly Horacio en España (1877) appealed only to students. He became famous, through his Ciencia española (1878), a collection of polemical essays defending the national tradition against the attacks of political and religious reformers. The unbending orthodoxy of this work is even more noticeable in the Historia de los heterodoxos españoles (1880–1886), and the writer was hailed as the champion of the Ultramontane party. As the Catholic Encyclopedia (1908–10) described his work, "Every page of his writings reveals a wealth of strong common sense, clear perception, and a vein of wonderful and ever varying erudition. Thoroughly Catholic in spirit, he found his greatest delight, he declared, in devoting all his work to the glory of God and the exaltation of the name of Jesus".
His lectures (1881) on Calderón established his reputation as a literary critic, and his work as an historian of Spanish literature was continued in his Historia de las ideas estéticas en España (1881–1891), his edition (1890–1903) of Lope de Vega, his Antología de poetas líricos castellanos (1890–1906), and his Orígenes de la novela (1905). Although some of his judgments, mainly those related to the defense of Spanish tradition, are no longer accepted, his studies of Spanish literature (Medieval, Renaissance, and Golden Age) are still valuable.
He was professor of Spanish literature at the University of Madrid (1878–98) and director of the Biblioteca Nacional de España (1898–1912).
He died at Santander. He is buried in Santander Cathedral, where his monument may still be seen.