An "exceptional and extraordinary" power outage has brought large parts of Portugal and Spain to a standstill.