The church was built in the second half of the 12th century by the provincial master of the Order of the Knights Templar in Portugal, Gualdim Pais. It was used as a burial place for the Knights Templar of Tomar and, later, by the Knights of the Order of Christ, which succeeded the Templars in the 14th century. Gualdim Pais is buried in the church, and his original tomb slab, dated from 1195 and bearing a gothic inscription, is still preserved inside