From 1580 to 1640 Spain and Portugal had the same monarch ruling over then, which is not quite becoming the same nation but is similar. Dom Sebastião (who was Portugal's king) died in 1578, his uncle took the throne but was already 70 years old and died shortly thereafter, and then Portugal had a succession crisis and there were three different contestants for the throne. The one who had acclaim of the Portuguese Council of Government was Filipe II of Spain, who became Filipe I of Portugal after some battles with António do Crato, one of the other contestants. His son Filipe III of Spain (Filipe II of Portugal) and grandson Filipe IV of Spain (Filipe III of Portugal) both ruled over Portugal, but Filipe IV was overthrown after the people rebeled and demanded a Portuguese monarch governing them.
Source: am Brazilian, study this in school because it relates to Brazil's colonial history.
Do you mean one nation with the capitol being in the peninsula? If you mean just that the entire peninsula was controlled by same country? The Roman Empire controlled entirety by late empire period (around 20 BC), when they conquered the area now known as Basque provinces.