The church was built atop the site of the no longer extant Castle de la Peña, of which only ruins remain. By 1180, the church had been made a collegiate church, staffed by Augustinian canons, and was much favored by the Aragonese royalty. The church was remodeled in 1343, but had to be rebuilt after the War of the Two Peters. In 1632 the parishes of this church and Santa María la Mayor were joined, and the church ultimately passed to the order of Franciscans. In 1649, it became the "Congregación de Esclavos de la Virgen de la Peña" ("Congregation of Slaves of the Virgen de la Peña").