Spanish and Portuguese are clearly closely related, but distinct languages. Do those two languages have a precursor other than Latin, from which they both descended, or is it more accurate to say that both descended directly from Latin, and are closely related because of geographic proximity and similarity of historical influences (or is this a poorly formed question)?
They are separate national languages, but there is, or at least used to be, a dialect continuum, where people could understand their neighbours, but differences increased with distance. They are definitely both classified as Western Romance languages with the precursor being Vulgar Latin; I do not remember the technical details, but I don’t think you could say they did not evolve directly from Latin. Same with Old French.
The Iberian Romance languages are interrelated, and, as DPRK states, they form a dialect continuum. It isn’t just Spanish and Portuguese. There are at least six major languages or dialect groups: Catalan/Valencian, Navarrese/Aragonese, Castilian, Aranese, Asturian/Leonese, and Portuguese/Galician. So, you see that one of the languages of Spain is actually grouped with Portuguese–those two languages are very close, if not indeed dialects of one language.
What we know as Standard European Spanish is actually a standardized dialect of Castilian, and it is known by that name in many Spanish-speaking countries. So, when you are comparing Standard European Portuguese and Standard European Spanish, you are actually comparing a standardized form of Portuguese/Galician with a standardized form of Castilian. If you had instead picked two standard forms based in languages that arose closer to each other, you would see much less difference between the two.
You can see here, that a detailed look at the languages of the Iberian peninsula is quite complex: Iberian languages - Wikipedia
You have to remember that even in the Roman times, Hispania was broken into provinces. There were people already living there who spoke a number of different languages… Iberian in the East, Aquitanian/Basque in the North, Lusitanian in the Northwest, Celtic, etc. So while Vulgar Latin would have been the lingua franca, the Iberian peninsula in Roman times would have been multilingual. After the fall of the Western Empire, the regional powers would develop their own languages based on locally available languages.
My impression is that standard Spanish and Portuguese are closer to each other than either is to Catalan. Catalan is actually a variety of the Langue d’Oc spoken in southwestern France.
At some point, this is just a question of labeling. Back a couple of thousand years ago, the language spoken in Iberia and the language spoken in Italy would both have been called “Latin”. Over time, differences accumulated gradually, and there was no single moment when speakers would have said “We’re not speaking Latin any more; we’re speaking Spanish”, or whatever. To within blurry lines, there was some point at which the languages spoken in Portugal, Spain, and Italy had detectable differences, but were still close enough to be called dialects of Latin, and there was some point at which the differences were enough to call them different languages. And you could doubtless find some time at which the difference between Portuguese and Spanish was still small enough, but the difference between either of those and Italian was large enough. But did anyone at that time actually use a single word for the Iberian languages, distinct from Latin? Does it matter?
It only matters for curiosity’s sake; if there was a time when the locals recognized that they were speaking something other than Vulgate Latin but before Portuguese and Spanish had differentiated, I’d be interested, that’s all.
It’s just Wikipedia, but the account linked below indicates that speakers in Iberia went more or less directly from (a) a fairly homogenous form of Vulgar Latin, to (b) their respective Romance languages.
The Iberian peninsula sustained major invasions/occupations in the 7th (Visigoths) and 8th (Arabs) centuries. That cultural upheaval likely played a role affecting whether or not locals still perceived themselves as speaking “Latin” or else adopting a different linguistic identity.
I’m not a linguist, but I’ve studied both languages to the point where I could speak and read them. Portuguese always struck me (glibly) as Spanish with missing letters, e.g., buenos dias = bom dia. Much of the language is somewhat similar to Spanish, but there are many words whose origins are a mystery to me, such as obrigado/a = gracias, which is “thank you” in both languages. The former almost sounds similar to the Japanese “arigato”. Also learning Spanish was far easier for me than Portuguese.
Portuguese was named and adopted as an official language instead of Latin in 1290 by King Dinis, when he chartered the university:
At the time it was known as “the common language” or “the language of the people” . In other words, people were obviously pretty aware of the fact they were not pronouncing or speaking Classical Latin, and they were aware there were different Romance vernaculars, but it took time, and politics, for national standards to be adopted and codified.
Galician and Portuguese are very similar. Portuguese has dialects, some I (half-Spaniard) understand easily, some I don’t understand at all (they swallow most vocals). Portuguese people understand Spanish much better than the other way around. I once had a delegate in a meeting in Brussels (I work as an interpreter) who was not allowed to speak Portuguese because it was not forseen in the language regime (that varies depending on the meeting, the availability of interpreters/booths, when the request for a language was made etc.) so he spoke Portuguese with a strange accent and claimed it was Spanish. Well, many delegates speak hideous English or French when they cannot speak their languages, and we interpreters have to cope as well as we can, so why not Spanish? He sounded just like Galician, and as it was supposed to be Spanish, we in the Spanish booth did not interpret him. That would have been disrespectful, I hope you understand. We had a lot of fun though. And one of my colleagues was by chance Galician and she said it what the delegate spoke was almost the Galician her grandmother spoke. Galician is very close to Portuguese and easy to understand for a Spaniard.
Franco outlawed all the languages in Spain except Castillian, what the rest of the world calls Spanish. He felt they threatened the unity of Spain and therefore his regime. He did many other stupid and/or repressive things: he was a dictator. That is what dictators do. He outlawed the teaching and the speaking of Catalan, Basque, Bable, Galician and other languages and dialects spoken in Spain in courts, schools, universities… but of course people kept speaking them in private, writing books and singing songs in them, and keeping them alive. People will always defend their identities and their past as long as they can. They do that all over the world. Quechua, Maya, Aztec in Midddle and South America. Native languages in the USA (read about Navajo during WWII, good story). Corse, Breton, Gaelic and Sardinian in France. Welsh, Gaelic and Scottish in the UK. Ukrainian in Ukraine. Swedish in Finland (yes, there is a Swedish minority there, and Swedish is now a co-official language in Finland). I believe that happens everywhere, and it is a good thing.
Portuguese underwent several spelling reforms, starting in 1911, and so did Spanish, except it started centuries earlier (the RAE was founded in 1713). Since the orthography reflects the (constantly changing) pronunciation to some extent, it is not surprising they are not the same today (even Portuguese vs Brasilian are not pronounced exactly the same, and that is the same language)