It was an open secret that Jose Luis RodrIguez Zapatero, leader of the Socialist Party (PSOE), expected to stay in opposition for the next four years. In Spain's brief history of post-Franco democracy, no party leader has ever made it to the prime ministerial residence, the Palacio de la Moncloa, at the first attempt. And the ruling right-wing Popular Party (PP), led by Jose-MarIa Aznar, could claim steady economic growth, low inflation and falling unemployment. Zapatero's advisers expected him to begin a comeback for the party in this year's election, but that was all.
If the landslide victory on Sunday 14 March - widely attributed to the PP government's handling of the Madrid bomb blasts that killed 200 people - came as a surprise to Zapatero, it must have been a still bigger shock to Tony Blair. In theory, the relationship between the two men should be very good. Both are lawyers. Both were elected in their early forties as leaders of supposedly unelectable parties that they have set about reforming.
But the two did not make a good start. After a visit to Seville two years ago Robin Cook, then still a cabinet minister, noted in his diary: "Over a cup of coffee . . . Zapatero . . . raised with me the . . . complaint that the only capital he had not been able to visit in the two years since taking over was London because he cannot get an appointment to see Tony Blair."
Zapatero did eventually get his invitation to No 10, but a much more recent visitor was the man Blair expected to win on 14 March: Aznar's designated successor, the PP's Mariano Rajoy. At the time, the visit went unnoticed in Britain, but the PP ensured that pictures of the beaming Rajoy standing outside No 10 with Blair got saturation coverage in Spain.
Blair's invitation to Rajoy was ill-advised, and all the more inexplicable because this was not government-to-government business. Rajoy had already resigned his position in cabinet to concentrate on preparing his election campaign. Had Blair stood in the centre of Madrid handing out leaflets for the PP, he could not have made his preference more clear. Socialist displeasure was summed up by one Spanish regional president who described Blair as "a prat".
But the relationship can be mended, even if it now never fulfils its potential. Despite the differences on Iraq - from where Zapatero is withdrawing Spanish troops - the new prime minister's views in several other areas will be welcome at No10. He will almost certainly abandon Aznar's intransigent refusal to accept the new European constitution, and if Spain reaches agreement on it, the Poles are unlikely to want to remain the sole, isolated opponents.
Zapatero is also enthusiastic about labour-market reforms, such as getting workers off what are known as "lifetime contracts", which make it virtually impossible for employers to sack them; Aznar talked about such reforms, but never actually did anything. In a new Labour spirit, the PSOE campaign included a commitment to spending much more of the national income on research and development. And while Zapatero never used the phrase "education, education, education", Socialists say it will be their priority in government. They want to equip every classroom with computer terminals and rapidly increase university funding.
There are other echoes of new Labour in economic policy. Not only did the PSOE pledge no increases in income tax and lower rates at the bottom end, it is also likely to choose as its finance minister Miguel Sebastian, an economist and banker who is not even a member of the party. By in effect outsourcing economic policy to an independent expert, the PSOE is trying to achieve much the same effect as Gordon Brown did when he made the Bank of England independent.
After his coffee-time chat with Zapatero in 2002, Cook offered his own explanation for Blair's reluctance to meet the PSOE leader: "The truth is that Tony does not have the tribal instinct to want to see other socialist leaders unless they are in government." For the good of the left in Europe, Blair must be more hospitable in future.