David I granted the chapel at Corstophine to Holyrood Abbey in 1128. By 1158, it had become a church, with altars to Saint Anne and the Holy Trinity.
A burial chapel was added to the church in 1404 by Sir Adam Forrester, who died by 1405. The chapel was dedicated to John the Baptist. The chapel was erected into a collegiate church by his son Sir John Forrester.
The foundation of the current church (on the inner eastmost wall) says the church was built in 1429 in the same churchyard as the earlier parish church, and was completed by 1437. The sandstone church was built with a tower and stone, octagonal spire, rectangular chancel, and a nave with transepts. This included the absorption of earlier Gothic features from the previous building and the erection of the characteristic barrel vaults, which may have concluded by 1436.
In 1634, the collegiate church was dissolved and in 1646 the building became the parish church. At that time the 12th-century church was razed and a new aisle was added to the collegiate fabric.Stones from the former church were used to built the porch. In 1828, a restoration by architect William Burn resulted in a two-storey sacristy, renovation of the nave, removal of a 17th-century aisle, and building of a new aisle and transept.
The nave of the church showing the concrete vaults, which replaced the original stone vaults in 1905.
The church has Scottish heraldic panels and pre-Reformation relics. James Ballantine supplied the Victorian stained glass and Gordon Webster and Nathaniel Bryson supplied the 20th-century windows. Leonardo da Vinci's Last Supper was the inspiration for the heads on the carved corbels made by William Birnie Rhind. On the grounds are a war memorial, vault and gatehouse, surrounded by a boundary wall and cast iron gates.
References:Visby Cathedral (also known as St. Mary’s Church) is the only survived medieval church in Visby. It was originally built for German merchants and inaugurated in 1225. Around the year 1350 the church was enlarged and converted into a basilica. The two-storey magazine was also added then above the nave as a warehouse for merchants.
Following the Reformation, the church was transformed into a parish church for the town of Visby. All other churches were abandoned. Shortly after the Reformation, in 1572, Gotland was made into its own Diocese, and the church designated its cathedral.
There is not much left of the original interior. The font is made of local red marble in the 13th century. The pulpit was made in Lübeck in 1684. There are 400 graves under the church floor.