A few kilometres to the north of Alcobaça is the wondrous building constructed in memory of the important battle of Aljubarrota that occurred in 1385. Dom João I defeated the Castilians and ensuring two hundred years of virtual independence from Spanish invaders. When the King Dom Fernando I died without an heir to the throne it was claimed by both his illegitimate brother Dom João I and Juan de Castile of Spain on behalf of his wife. On the 14th of August of that year the outnumbered army of Dom João I commanded by an outstanding general, Nuno Álvares Pereira, faced the Spanish forces just south of the present site of the Abbey. It is said that on the eve of the battle Dom João made a vow to construct an unforgettable church in memory of the Virgin Mary should he succeed in battle the next day.