Though a victory was soon gained over the Spaniards at Montijo, the war dragged on for twenty-eight years, and it was only some years after Don John of Austria[168] had been defeated at Almeixial by Schomberg (who afterwards took service under William of Orange) that peace was finally made in 1668. Portugal then ceded Ceuta, and Spain acknowledged the independence of the revolted kingdom, and granted to its sovereign the title of Majesty.

It is no great wonder, then, that with such a long-continued war and an exhausted treasury a building like Santa Engracia should have remained unfinished, and it would have been well for the architecture of the country had this state of poverty continued, for then far more old buildings would have survived unaltered and unspoiled.

Unfortunately by the end of the seventeenth century trade had revived, and the discovery of diamonds and of gold in Brazil had again brought much wealth to the king.

Of the innumerable churches and palaces built during the eighteenth century scarcely any are worthy of mention, for perhaps the great convent palace of Mafra and the Capella Mor of the Sé at Evora are the only exceptions.

In the early years of that century King João v. made a vow that if a son was born to him, he would, on the site of the poorest monastery in the country, build the largest and the richest. At the same time anxious to emulate the glories of the Escorial, he determined that his building should contain a palace as well as a monastery—indeed it may almost be said to contain two palaces, one for the king on the south, and one on the north for the queen.

Mafra.

A son was born, and the poorest monastery in the kingdom was found at Mafra, where a few Franciscans lived in some miserable buildings. Having found his site, King João had next to find an architect able to carry out his great scheme, and so low had native talent fallen, that the architect chosen was a foreigner, Frederic Ludovici or Ludwig, a German.

The first stone of the vast building was laid in 1717, and the church was dedicated thirteen years later, in 1730.[169]

The whole building may be divided into two main parts. One to the east, measuring some 560 feet by 350, and built round a large square courtyard, was devoted to the friars, and contained the convent entrance, the refectory, chapter-house, kitchen, and cells for two hundred and eighty brothers, as well as a vast library on the first floor.

The other and more extensive part to the west comprises the king's apartments on the south side, the queen's on the north, and between them the church.