The opposition in Venezuela has won a majority of seats in the National Assembly, overturning nearly two decades of dominance by the Socialists of President Nicolas Maduro.

Five hours after polling ended, the National Electoral Council announced the opposition had won 99 seats.

It is the worst-ever defeat for the leftist movement founded by former leader Hugo Chavez in 1999.

The Socialists have gained 46 seats, with another 22 yet to be declared.

Results arrived much later than expected, five hours after polls closed. Fireworks erupted over the capital, Caracas, soon after.

Among the campaign issues were chronic food shortages of staples - such as milk, rice, coffee, sugar, corn flour and cooking oil.

image copyright Reuters

Venezuela has been hit hard by the continuing low price of oil, its main export. It also has the continent's highest inflation rate.

Mr Maduro has blamed the situation on an "economic war" waged by the opposition.

The reaction

image copyright AFP/Getty Images image caption Nicolas Maduro conceded in a live televised address

"We have come with our morals and our ethics [intact] to recognize these adverse results, to accept them and to say to our Venezuela that the constitution and democracy have triumphed.

"We have lost a battle today, but the struggle to build a new society is just beginning." - Nicolas Maduro, Venezuela's president and head of the United Socialist Party of Venezuela.

image copyright Reuters image caption Henrique Capriles once ran for the presidency

Henrique Capriles, a leading opposition figure in the Democratic Unity Roundtable and a former presidential challenger. "The results are as we hoped. Venezuela has won. It's irreversible," tweeted (in Spanish), a leading opposition figure in the Democratic Unity Roundtable and a former presidential challenger.

"Venezuela wanted a change and that change came. A new majority expressed itself and sent a clear and resounding message." - Jesus Torrealba - opposition coalition chief.

What happens now?

The opposition alliance, made up of centrist and conservative parties, is confident of ultimately taking at least 112 seats after 16 years of socialist control.

According to senior figures in the alliance, that would allow them to pass laws allowing the release of political prisoners and to reverse, for example, appointments to senior legal positions made by the current government, says the BBC's Wyre Davies, in Caracas.

image copyright Reuters image caption Humberto Lopez, a Venezuelan Che Guevara impersonator, reacts to the ruling party's defeat

It also gives stronger momentum to the opposition should it wish to call a referendum on Mr Maduro's future. This could take place only when his presidency reaches its halfway point in April next year.

However, under Venezuela's presidential system the United Socialist Party of Venezuela (PSUV) will still be a powerful force, as it controls many municipalities.

The next presidential election is due in April 2019.

Why does the result matter?

It is the first time in 16 years that the PSUV is not in control in Congress - a serious blow to its socialist revolution

At 74.3%, voter participation was high, suggesting a sizeable proportion of the population backed change

The opposition will pose a serious challenge to the government's power to pass legislation

Jailed opposition leaders could be released if the opposition makes good on its promise to pass an amnesty law

It is another blow to left-wing policies in Latin America, coming two weeks after a centre-right candidate won in Argentina's presidential poll

How the campaigns were run

The elections were widely seen as a referendum on President Maduro, the handpicked successor of the late President Hugo Chavez, and the party's socialist policies.

The opposition accused the PSUV of mismanaging the economy and of squandering the country's oil wealth.

Mr Maduro says his party defends the interests of ordinary Venezuelans and wants to complete Mr Chavez's "Bolivarian Revolution".

The opposition also accused the government of increasing authoritarianism.

Earlier this year, opposition leader Leopoldo Lopez was given a 13-year prison sentence for inciting violence - a charge critics say was politically motivated.