The castle was founded by the Order of Poor Knights of the Temple in 1118. Its construction continued until the final part of the 12th century with the construction of the oratory, in one of the angles of the castle, completed by the Grand Master D. Gualdim Pais sometime around 1160. In 1190 it resisted a major attack from the armies of caliph Abu Yusuf al-Mansur, who was successful in taking strongholds in the south. A plaque was erected near the entrance to the castle to commemorate this event.
During the second quarter of the 13th century, Tomar was transferred into the control of the Templars, becoming its seat. The castle became an integral part of the defence system created by the Templars to secure the border of the young Christian Kingdom against the Moors, which at the time occupied the area to approximately the Tagus River. But, following the dissolution of the Templar Order, on 14 March 1319, and following the request of King Denis of Portugal, Pope John XXII instituted the Order of Christ. The seat of the former Knights Templar was converted in 1357 into the seat of this new order.
The famous round church (rotunda) of the castle of Tomar was also built in the second half of the 12th century. The church, like some other templar churches throughout Europe, was modelled after the Dome of the Rock in Jerusalem, which was believed by the crusaders to be a remnant of the Temple of Solomon. The Church of the Holy Sepulchre of Jerusalem may also have served as model.
Following the dissolution of the Templar Order, on 14 March 1319 (following the request of King Denis of Portugal), Pope John XXII instituted the Order of Christ. The Templar order had been suppressed during most of Europe from 1312 to 1314, but in Portugal its members, assets, and partly its membership were transferred to the Order of Christ. The seat of the former Knights Templar was converted in 1357 into the seat of this new order.