When the capital of Spain was transferred from Toledo to Madrid in 1561, the seat of the Church in Spain remained in Toledo and the new capital had no cathedral. Plans to build a cathedral in Madrid dedicated to the Virgin of Almudena were discussed as early as the 16th century but even though Spain built more than 40 cities in the new world during that century and plenty of cathedrals, the cost of expanding and keeping the Empire came first and the construction of Madrid's cathedral was postponed. Making the cathedral the largest that the world had ever seen was then a priority, all other main Spanish cities had centuries old cathedrals, Madrid also has old churches but the construction of Almudena only began in 1879.
The cathedral seems to have been built on the site of a medieval mosque that was destroyed in 1083 when Alfonso VI reconquered Madrid.
Francisco de Cubas, the Marquis of Cubas, designed and directed the construction in a Gothic revival style. Construction ceased completely during the Spanish Civil War, and the project was abandoned until 1950, when Fernando Chueca Goitia (es) adapted the plans of de Cubas to a baroque exterior to match the grey and white façade of the Palacio Real, which stands directly opposite. The cathedral was not completed until 1993, when it was consecrated by Pope John Paul II. On May 22, 2004, the marriage of King Felipe VI, then crown prince, to Letizia Ortiz Rocasolano took place at the cathedral.
The Neo-Gothic interior is uniquely modern, with chapels and statues of contemporary artists, in heretogeneous styles, from historical revivals to "pop-art" decor. The Blessed Sacrament Chapel features mosaic from known artist Fr. Marko Ivan Rupnik.
The Neo-Romanesque crypt houses a 16th-century image of the Virgen de la Almudena. Nearby along the Calle Mayor excavations have unearthed remains of Moorish and medieval city walls.
On April 28, 2004, Cardinal Antonio María Rouco Varela, Archbishop of Madrid, blessed the new paintings in the apse, painted by Kiko Arguello, founder of the Neocatechumenal Way.