A church on the site was built originally in the 1220’s but was rebuilt following its destruction during the Mongol Invasion of Poland in 1240 – 1241. This is commemorated to this day when every hour, a trumpet signal - called the Hejnal mariacki - is played from the top of the taller of St. Mary's two towers. This breaks off suddenly to commemorate the fact that the trumpeter was shot in the throat while sounding the alarm before the Mongol attack on the city.
The Gothic Church replaced the original Romanesque design but used the original foundations. Constructed in the years 1290 - 1300 it was not consecrated until 20 years later in 1320. In the years between 1355 and 1365 in the reign of Casimir III (1333 - 1370) the church was completely rebuilt. In 1365 a chancel (or presbytery) was added with its splendid large stained-glass windows, three of which are still in place.
In the first half of the 15th century, the side chapels were added and the northern tower was raised in order to enable it to serve as the watch tower for the city. In 1478 a helmet was added to the tower and in 1668 a gilded crown was placed on top, raising its height to 80 m (262 ft). It is said that the crown contains the written history of the city. The lower tower is 69 metres high with a roof in Renaissance style built in 1592. This houses five bells two of which date back to the late 14th century.
The main body of the church was completed in 1395 - 1397 when a new vault was added. However, the vault over the chancel collapsed in 1442 which was believed to have been the result of an earthquake.
Located behind the High altar is the Altarpiece of Veit Stoss for which the church is famous. The Altarpiece is the world’s largest Gothic altarpiece (about 13 metres high and 11 metres wide) and is one of Poland’s National Treasures. It was carved between 1477 and 1489 by the German sculptor Veit Stoss (Wit Stwosz) who lived in the city for 20 years. In 1491 he sculpted the stone crucifix that now is part of the late-Baroque altarpiece in the south aisle, and is credited with the large crucifix above the nave.
In the 18th century, the interior was rebuilt in the late Baroque style. This involved the replacement of its 26 altars, equipment, furniture, benches and paintings. The front porch dates from the mid-18th century.
At the beginning of the 19th century, the cemetery near the Basilica was closed and became a public square. In the years 1887 - 1891, the church was redesigned to the neo-Gothic design.
In 1941, during the German occupation, the Altar was dismantled and shipped to Bavaria where it was recovered in 1946 in the basement of Nuremberg Castle. The Altar was returned to Poland and underwent major restoration work; it was reinstalled in the Basilica in 1956.
Today the Basilica’s twelve chapels house numerous Sepulchral artefacts and its ornate stalls in the chancel are a good example of early-Baroque woodwork. The wall paintings of Jan Matejko date back to the 1888 - 1891 renovation. Its treasure-house contains a priceless collection of objects, including some 300 masterly embroidered ancient vestments.