Venezuela's governing United Socialist Party (PSUV) has won the greatest share of the vote in Sunday's local elections, the National Electoral Council has said.
With most votes counted, the PSUV has 49% while the opposition has about 43%.
The opposition were ahead in most of the larger cities, including the capital, Caracas, while the governing party won in rural areas.
The elections have been seen as a key test for President Nicolas Maduro.
Mr Maduro became president in April, after the death from cancer of Hugo Chavez.
In November, the National Assembly gave him powers to govern by decree, a measure he says he will use to to tackle corruption and control price rises.
The opposition accuses him of failing to deal with crime, inflation and a shortage of basic goods.
The BBC's Irene Caselli in the capital, Caracas, says local elections are usually low key, but this one was filled with expectations for the government and the opposition.
Voters were electing mayors to 337 municipalities and officials to more than 2,000 city councils.
The opposition won mayoral races in the capital, Caracas, and the second city, Maracaibo.
They also won the capital of Barinas, the state from which Mr Chavez hailed.
Electoral officials said on Monday evening that the PSUV had won in 196 of the municipalities being contested, while the opposition took 53, and independents another eight, with the remainder yet to be declared.
President Maduro later said his party had taken 210 municipalities, but there has so far been no official confirmation of this figure.
He called the results a "grand victory", telling supporters at a rally in Caracas that "the Bolivarian Revolution continues now with more strength".
The opposition's failure to win a majority of the votes cast or significantly increase the number of municipalities under its control from the 46 won in the 2008 local elections was a disappointment to its leader Henrique Capriles.
"I did everything humanly possible," he said. "Remember that Venezuela does not have a single owner. A divided country needs dialogue."
Sunday's elections coincided with the anniversary of Hugo Chavez's famous speech in which he announced that his cancer had returned and named Mr Maduro as his preferred successor.
Mr Maduro was granted special powers to rule by decree for a year to deal with Venezuela's economic crisis.
Since then he has legislated on the prices of electronics, toys, clothes and cars.
The opposition says the government's left-wing policies are keeping foreign investment away and hurting the economy.