According to tradition this statue, Our Lady of Almudena, was carved out of cedar and juniper by Saint Nicodemus to propagate devotion to the Virgin Mary. It was polychromed by Saint Luke. The apostle Saint James gave it to Saint Calocero, who built a small chapel where it was displayed on the height of Cuesta de la Vega in present day Madrid. This sanctuary was free of the profanations during the persecutions suffered by the Christians in Gothic Spain. It became a large church during the fourth century under the Emperor Constantine.
During the Arab invasion of the 8th Century, the Christians of Old Madrid hid the image of Mary to avoid its being profaned or destroyed. It was sealed in a niche formed in one of the dados of the ramparts in a section close to the shrine. Once the statue was placed there in the year 714, they covered the place over so that it looked like an ordinary mending of the ramparts.
For three centuries and a half the Mohammedans were in Madrid. The shrine was briefly turned into a Mosque, but in 1083 Alfonso VI conquered Madrid and after the old shrine was purified and converted back into a church dedicated to Mary. King Alfonso ordered that on the wall of the major chapel a picture of the Blessed Virgin be painted to take the place of the lost image. In the course of centuries knowledge of the whereabouts of the statue had been hidden and lost.
After many efforts, the king decided to celebrate a novena of prayers, fasts, and penances as well as almsgiving, asking heaven to grant that the image be found. At the end of the novena, a procession took place on November 9, 1085. It was supposed to leave the church of Our Lady and march around the walls of the city. When the procession, in which the king himself and many other notables marched, came opposite to where the statue was hidden, the stones of the wall fell away and the statue was revealed in the niche with two candles on either side that were still miraculously alight, having burned continuously for over three-hundred years!
The next day the statue was taken to the church. All of Madrid celebrated a festival of great jubilation. The statue was borne by four prelates and carried to the church of Our Lady. It was given the name of Nuestra Senora de la Almudena, Our Lady of Almudena, for the statue was hidden near a Moorish granary or “almudith”.
King Alfonso VI ordered the building of a larger church which was given over to the Augustinians. In 1664 the municipal government of Madrid decided to participate in the feast and the procession celebrated in honor of the Holy Patroness.
When the church was torn down in 1868, the statue was taken to the church in the Calle del Sacramento.
Source: www.roman-catholic-saints.com