The church of Nossa Senhora da Piedade was built in 1664 at the royal initiative of D. Afonso VI, when the area around Paço Real was restructured, which stood in the place where the Seminary College is currently located. This king intended to thank the Miracle of Nossa Senhora da Piedade, which occurred on May 27, 1663, and which would contribute, according to popular and religious belief, to victory in the Battle of Ameixial