From the late Middle Ages, in the 15th and 16th centuries, Portugal ascended to the status of a world power during Europe's "Age of Discovery" as it built up a vast empire, including possessions in South America, Africa, Asia, and Oceania. Over the following two centuries, Portugal kept most of its colonies, but gradually lost much of its wealth and status as the Dutch, English, and French took an increasing share of the spice and slave trades by surrounding or conquering the widely scattered Portuguese trading posts and territories. Signs of military decline began with two disastrous battles: the Battle of Alcácer Quibir in Morocco in 1578 and Spain's abortive attempt to conquer England in 1588 by means of the Spanish Armada – Portugal was then in an uncomfortable dynastic union with Spain and contributed ships to the Spanish invasion fleet. The country was further weakened by the destruction of much of its capital city in an earthquake in 1755, occupation during the Napoleonic Wars and the loss of its largest colony, Brazil, in 1822. From the middle of the 19th century to the late 1950s, nearly two