Claim: Portugal shares a border.

Portugal -LRB- Portuguese : -LSB- puɾtuˈɣaɫ -RSB- -RRB- , officially the Portuguese Republic -LRB- -LSB- República Portuguesa , links = no -RSB- -RRB- -LRB- Portuguese : -LSB- ʁɨ ` publikɐ puɾtu ' ɣezɐ -RSB- -RRB- In recognized minority languages of Portugal :  República Pertuesa is a sovereign state located on the Iberian Peninsula in southwestern Europe . It is the westernmost country of mainland Europe . To the west and south it is bordered by the Atlantic Ocean and to the east and north by Spain . The Portugal -- Spain border is 1214 km long and considered the longest uninterrupted border within the European Union . The republic also includes the Atlantic archipelagos of the Azores and Madeira , both autonomous regions with their own regional governments .   The territory of modern Portugal has been continuously settled , invaded and fought over since prehistoric times . The Pre-Celts , Celts , Carthaginians and Romans were followed by the invasions of the Visigothic and the Suebi Germanic peoples . Portugal as a country was born in the aftermath of the Christian Reconquista against the Moors who had invaded the Iberian Peninsula in 711 AD and occupied most of it ever since . Precipitated by the seminal event for its foundation , the Battle of São Mamede , where Portuguese forces led by Afonso Henriques defeated forces led by his mother Theresa of Portugal and her lover Fernão Peres de Trava , which established the nation 's sovereignty against rival neighbor kingdoms . Following São Mamede , the future king styled himself Prince of Portugal . He would be proclaimed King of Portugal in the Battle of Ourique in 1139 and was recognised as such by neighbouring kingdoms in 1143 .   In the 15th and 16th centuries , Portugal established the first global empire , becoming one of the world 's major economic , political and military powers . During this time , Portuguese explorers pioneered maritime exploration in the Age of Discovery , notably under royal patronage of Prince Henry the Navigator and King João II , with such notable discoveries as Bartolomeu Dias 's reach of the Cape of Good Hope -LRB- 1488 -RRB- , the Vasco da Gama 's sea route to India -LRB- 1497 -- 98 -RRB- and the discovery of Brazil -LRB- 1500 -RRB- . Portugal monopolized the spice trade during this time , and the Portuguese Empire expanded with military campaigns led in Asia . But the destruction of Lisbon in a 1755 earthquake , the country 's occupation during the Napoleonic Wars , the independence of Brazil -LRB- 1822 -RRB- , and the Liberal Wars -LRB- 1828 -- 34 -RRB- , all left Portugal crippled from war and diminished in its world power .   After the 1910 revolution deposed the monarchy , the democratic but unstable Portuguese First Republic was established , later being superseded by the Estado Novo right-wing authoritarian regime . Democracy was restored after the Portuguese Colonial War and the Carnation Revolution in 1974 . Shortly after , independence was granted to almost all its overseas territories . The handover of Macau to China in 1999 marked the end of the longest-lived colonial empire . Portugal has left a profound cultural and architectural influence across the globe and a legacy of over 250 million Portuguese speakers today .   Portugal is a developed country with a high-income advanced economy and a high living standard . It is the 5th most peaceful country in the world , maintaining a unitary semi-presidential republican form of government . It has the 18th highest Social Progress in the world , putting it ahead of other Western European countries like France , Spain and Italy . A founding member of NATO and the Community of Portuguese Language Countries , it is also a member of numerous other international organizations , including the United Nations , the European Union , the eurozone , and the OECD .   Portugal is a pioneer when it comes to drug decriminalization , as the nation decriminalized the possession of all drugs for personal use in 2001 .   LGBT rights in Portugal have improved substantially in the past two decades and are now among the best in the world . Moreover , after years of investment and cooperation , Portugal marked a climax on renewable energy worldwide in 2016 , when it was powered for 107 consecutive hours exclusively by wind , sun , and water , which advocates say further shows fossil fuels are indeed replaceable .