CARACAS, Venezuela — Government opponents surged to a rare victory here on Sunday in key congressional elections framed by the country’s deep economic crisis, claiming a legislative majority for the first time in years and handing a significant setback to the heirs of former president Hugo Chávez and his socialist inspired movement.
The victory significantly alters the political balance in this deeply divided country and augurs a power struggle between the long marginalized opposition and the government of President Nicolás Maduro, the successor and disciple of Mr. Chávez.
Tibisay Lucena, the head of the electoral commission, announced at about 12:30 a.m. Monday that the opposition, represented by the Democratic Unity coalition, had won 99 seats and the government’s United Socialist party had won 46 seats. She said final results were not in for 22 seats.
“The results are what was hoped for!” the former opposition presidential candidate, Henrique Capriles, wrote on Twitter. “Venezuela won! Irreversible!”
As word filtered out that the opposition coalition, which includes a range of parties, had won a majority of seats, activists at the group’s election-night headquarters in a Caracas hotel smiled broadly and exchanged high fives.
“We are entering a period of transition,” said Henry Ramos, an opposition leader who predicted the coalition had received more than 100 seats in the 167-seat National Assembly. “The government is very weak.” He predicted that Mr. Maduro would not reach the end of his term in 2019 and that he would be removed by “constitutional means,” such as a recall referendum, a change to the Constitution, or by being forced to resign.
Government officials had remained silent and out of sight until late in the night, and a stage that had been set up in central Caracas for a government party celebration was taken down before midnight.
Mr. Maduro, who has vowed to continue the socialist-inspired policies of his mentor, Chávez, has struggled to address triple-digit inflation, a two-year recession and other economic challenges. Venezuela depends heavily on income from oil production, and the sharp drop in petroleum prices has starved the government of money.
At many polling sites in Caracas voters showed up as early as 5 a.m. While opposition activists reported some irregularities — including confrontations between supporters of different parties and scattered delays caused by malfunctioning digital voting devices — voting in general appeared to go on in an atmosphere of calm.
“I always used to support the government, but not anymore,” said Gabriela León, 37, after casting her ballot in a hilltop slum long known as a pro-government bastion. “I feel let down.” She said that she was fed up with rising prices, long lines to buy food and other necessities and rampant crime. “I want my kids to grow up in a safe place, in a pretty country,” she said.
Mr. Maduro tried to cast the election in terms of left versus right, good versus evil, loyalty to Mr. Chávez’s legacy versus betrayal. But for many it had less to do with questions of ideology and more to do with exasperation over a catastrophic economy and a government mired in indecision and corruption.
Mr. Maduro said before the vote that an opposition victory would be a nightmare and that he would take to the streets in rebellion in that case — an unusual suggestion by a sitting president who still controls most levers of power. The government entered the balloting carrying a heavy burden amid two years of recession expected to represent a shrinking of economic production of about 15 percent.
Many voters said that they did not know the names of the opposition candidates they were voting for, nor cared — they planned to press the symbol of the opposition Democratic Unity coalition on the touch-screen ballot, a potent, anyone-but-these-guys rejection of the governing United Socialist Party.
José Hernández, an administrator in a government ministry, had a hard time coming up with the name of the opposition candidate he planned to vote for, saying in the end that he would simply look for the thumbs-up symbol of the opposition coalition.
“I’m voting for the party, for change,” he said, referring to the unity coalition. Mr. Hernández said that he had always voted for Mr. Chávez’s movement. But now he said, “They’ve had so much time in power it’s time to bring in someone else.”
Patricia Torres and María Eugenia Díaz contributed reporting.