Well, there was a period of 60 years (1580-1640) were Spain did control Portugal. The Spanish invasion of 1580 was brought about by extraordinary circumstances- the near complete extermination of the Joanine dynasty in Morocco, a strong Spanish military presence, a fear that other dynastic heads would step in the vacuum- that Spain to successfully invade Portugal. The country itself is fairly hard to invade and conquer quickly as there is a limited window for operations and the terrain lends itself to defensive warfare.
You might want to check out the answers to this question- Why Spain has never invaded/kept Portugal under its reign? which has some good links to answers in the faqs.