Portuguese, like its Romance-language siblings and cousins, is an Indo-European language derived mainly from Vulgar Latin.
At one point, Portuguese and Spanish (Castilian) were just local dialects of a provincial patois of Latin, brought to the Iberian peninsula by the Roman soldiers and civilian colonists. The pre-Roman inhabitants of northwestern Iberia were largely of Celtic origin, and very little of their original language has survived. South of them lived the Lusitanian people, also of ancient origin. In 216 BCE the Romans occupied Iberia (which they called "Hispania") until 409 CE, when they were supplanted by Visigoths from over the Pyrenees. Three centuries later, Moors invaded, spreading an Arabic influence will into the north and west of the peninsula, remaining for several hundred years. Unlike many of the eastern Iberian languages, Galician and Portuguese were relatively unaffected by the Gothic and Arabic influences, though the territory now known as Portugal was invaded more than once in very early times by Punic populations from Carthage. Thus the Arabic influences in Portuguese are somewhat less and of a slightly different character than the Arabic influences that have survived in modern Spanish. (For example, Portuguese uses the word of Latin origin for "rug" - tapete - whereas Spanish uses the Arabic-origin word, alfombra.) Of course, in the southern areas of Portugal, much more influence was felt, especially with the names for food items and place names.
The land of the inhabitants of what is now Portugal, south of the Douro River, was called "Lusitania" by the Romans, and the adjectival form, luso-, is still used to describe the people and language of Portugal. "Portuguese" derives from the language of the people of an important city within the territory, "O Porto" - literally, "The Port." Eventually O Porto lent its name to the entire country, the language itself, and a very fine wine of which the English became very fond in the 18th and 19th centuries. "Galicia" was a Romanization of the Celtic name of the territory of the Celts to the north of the Douro River and also towards the east of Portugal, and the language, called Galician in English and "gallego" or "gallego-portugués" in Spanish, is a dialect that spans the gap between Spanish and Portuguese. It is highly intelligible to speakers of either language.
The Romans battled the locals for over two centuries in the west of the peninsula before eventually subduing them. First there were the Carthaginians, and then the local Celts and Lusitanians. By 26 CE, Emperor Caesar Augustus declared the conquest complete, and named the territory "Hispania." There were three administrative provinces: Hispania Terraconensis, Hispania Baetic, and Lusitania. This last province comprehended most of what is modern Portugal.
Entering the Iberian peninsula from the north in the fifth century, the Goths settled in various parts of Spain, but another Germanic marauding tribe from the Rhine region, called the Suevi, settled in a part of what is now Galicia. The Suevi kingdom lasted from 410 until 584, when it was conquered by the Visigoths. The Seuvi set up their capital in Braga in Galicia. Another group that migrated with them were called "the Buri" and they settled in what is now known as Terras do Bouro. The invading Germanic tribes adopted the local version of Vulgar Latin, leaving little of their own native tongue in the mixture, besides place names, some family names and a few words associated with warfare (like "guerra").
As early as the 9th century manuscripts of administrative documents show a mixture of the colloquial Romance speech with more official and formal Latin, thus helping to define a transitional tongue called "proto-Portuguese." Somewhere around the 12th century, "Galician-Portuguese" emerged as the local language for "Galicia," a region including the northern part of Portugal as well as the province now known as Galicia. This language was the preferred language of Christian writers of tracts, poems and songs, even in other parts of re-conquered Spain. The Castilian King Alfonso el Sabio (Alfonso X) was said to have preferred Galician to Castilian for use in writing and at the court. Southern Galician became modern Portuguese.
In 1143, the Kingdom of Leon, which included Galicia at the time, recognized an independent country called Portugal. Its first king was Afonso Henriques. By the 1290 the Portuguese University had been established in Lisbon, and that "Portuguese," not Latin, was to be the operative language. This was one of the first recorded references to the language by its modern name. The first period of "Old Portuguese" is judged to be from the 12th to the 14th centuries.
The time of the great discoveries by Portuguese sailors falls in the second period of "Old Portuguese" -- from the 14th to the 16th centuries. It was a lingua franca in Asia and Africa for all communication between locals and Europeans. Many vestiges of Portuguese still exist in Asia and Africa, particularly in East Timor, Sri Lank, Goa, and in parts of Malaysia and Indonesia. In Japan, words like "tempura" (from tempero) and "pan" (from pão) are still in use. In Indonesia, "sepatu" (from sapato) means "shoe." The Swahili word "meza" comes from "mesa" and in Malay, "keju" means "cheese" (from queijo).
Scholars usually mark the beginning of modern Portuguese with Garcia de Resende's publication in 1516 of the Cancioneiro Geral. Modern Portuguese expanded by the re-importation of Latin terms of more erudite ancestry than Vulgar Latin, and also by many words of Greek origin, which had also been adopted into modern Spanish as well.