Venezuela's opposition has won control of the country's legislature for the first time in 16 years.
Voters took the opportunity to punish the socialist government for an economic crisis and insecurity in the oil-rich nation.
Venezuela's President Nicolas Maduro promptly accepted the defeat, a blow to his leadership and the "revolution" of "21st century socialism" launched by his late predecessor Hugo Chavez.
The result was a triumph for the centre-right opposition, which has struggled for years for a foothold and has seen many of its leaders jailed.
The Democratic Unity Roundtable (MUD) coalition won a majority of 99 out of 167 seats in the state legislature, the head of the National Electoral Council (CNE), Tibisay Lucena, announced shortly after midnight, five hours after polls closed.
Fireworks erupted over the capital Caracas as opposition supporters celebrated.
"Venezuela has won," tweeted Henrique Capriles, leader of one of the parties in MUD.
It was unclear, however, how far the MUD will be able to push its advantage in congress to force a change of course or even to get rid of Maduro, who vowed to push on with his socialist programs.
"We have come with our morals and our ethics to recognise these adverse results, to accept them and to say to our Venezuela that the constitution and democracy have triumphed," the 53-year-old said in a televised address.
"We have lost a battle today, but the struggle to build a new society is just beginning."