For once the opinion polls got it right. Despite a bout of last-minute nerves, Jose Luis Rodriguez Zapatero and his Socialist party have gained a second term with a slightly increased representation in the Spanish parliament, although still just short of an absolute majority. That must be good for Spain. Although the government of Mr Zapatero has pushed bravely on with policies of social concern and secular liberalism, most notably on gay marriage, there was always the charge that they had somehow gained power by accident because of the peculiar circumstances of the 2004 Madrid bombings in which the last election had been held. If the government was to proceed with its policies then it needed the authority of a popular mandate.
It was a bitter and often nasty campaign in which the right of the Popular Party exploited every issue, from immigration to marriage, to attack the prime minister. It failed to get its man. In two other ways, as well, Spain's election is of clear benefit to the country. One is in its dealings with Europe. Although Mr Zapatero was quick to fulfil his promise of withdrawal of Spanish troops from Iraq, on more general foreign policy, and particularly in his dealings with Europe, he has had been notably less forthcoming. With a clear mandate and four years in office, Spain can now play a more active role in the EU at a time when French, German and British leadership are all faltering on the issue. At the same time, the election marked a clear and possibly decisive vote in favour of the moderate nationalist parties at the expense of the extremes. Against all the fears of those who were predicting an imminent break-up of the country, voters in the Basque country and Catalonia voted for parties committed to working within the system – a lesson for other European countries, including Britain. At this stage Mr Zapatero is unlikely to seek a coalition with any of the smaller parties, preferring to seek support on an ad hoc basis. But he is likely to work with the mainstream nationalists, meaning moderation will be rewarded. Yet there is need for caution in applauding Zapatero's victory.
The result still leaves Spain a sharply divided country. If the Socialists gained five seats, so did the Popular Party. Both improved their share of the vote. Immigration remains a fraught issue. The bishops may be down but they are still far from out and the Madrid government is facing an economic downturn.
Mr Zapatero spoke yesterday of inaugurating a new era in Spanish politics and seeking national unity after the divisiveness of the campaign. These are fine intentions, but, with a recession in the offing and a fiercely divided electorate, fulfilling them may not prove such a straightforward task.