Eastern trade brought incredible wealth, but military defeat in Morocco mean that the prosperity was short-lived. Spain invaded in 1580 and Spanish kings rule Portugal for next 60 years. After Portugal regained independence and fortunes were restored by the discovery of gold in Brazil. In the second half of the 18th century, the chief minister, the marques de Pombal, began to modernize the country and to limit the reactionary influence of the church. However, Napoleon’s invasion in 1807 and the loss of Brazil in 1825 left Portugal improverished and divided. Power struggles between Absolutists and Constitutionalists further weakened the country, and despite a period of stability form the 1850s. The debt crisis worsened. In 1910, a republican revolution overthrew the monarchy.