Spain's governing Socialists and opposition Popular Party are running almost neck-and-neck in the country's regional and municipal elections.
The opposition Popular Party seems to be closing the gap
With virtually all the votes counted, the Popular Party had 36% support, one percentage point more than the Socialists, who won more seats.
Correspondents say Sunday's poll provided few pointers to the likely result of next year's general election.
The vote is seen as a first real popularity test for the Socialists.
They came to power in March 2004, following an election three days after train bomb attacks in Madrid that killed 191 people.
National issues such as violence in the Basque region and urban planning corruption have loomed strongly.
For the first time, many British and German expatriates have put themselves forward as anti-corruption candidates.
The political make-up of more than 8,000 town councils and most of the country's regional governments is being decided in Sunday's polls.
The Socialists retained Seville and Barcelona, while the Popular Party (PP) held onto Madrid and Valencia. But the PP's majority in Navarra was threatened by a surge by Basque nationalists.
In the Basque region, the moderate nationalist party, the PNV, remains the main political force.
The ANV, the party supported by Batasuna, the illegal political group linked to the militant separatists Eta, had moderate success in one Basque province, winning 15% of the vote.
The vote follows the national government's first major setback, says the BBC's Danny Shaw in Madrid.
In December, an Eta bomb attack put an end to the peace process led by Prime Minister Jose Luis Rodriguez Zapatero.
The Popular Party had wanted to capitalise on that failure, our correspondent says, but the election result seems conclusive.
Corruption in town planning is another big issue. A number of new political groups have been influenced by the issue.
For the first time, independent political parties with more non-Spanish than Spanish candidates, including many Britons and Germans, are taking part in elections.