President Hugo Chavez's allies won a strong majority in Venezuela's local elections, but the socialist leader's opponents made important gains, capturing the Caracas mayor's office and two of the most populous states.

Chavez trumpeted his party's domination of Sunday's vote as "a sign" for him to continue driving Venezuela toward "21st-century socialism." With more than 95 percent of votes counted, pro-Chavez candidates held on to gubernatorial posts in 17 states, while the opposition won five states.

"The people are telling me: 'Chavez continue down the same road,"' said Chavez, hinting that he has not abandoned plans for constitutional changes that would expand his powers, push the economy toward socialism and allow him run for re-election indefinitely.

Voters rejected the president's proposed overhaul of the constitution last year.

Tibisay Lucena, president of Venezuela's election council, said the opposition won in the two most populous states — Miranda and Zulia — as well as Nueva Esparta, Carabobo and Tachira. Opposition leader Antonio Ledezma defeated a close Chavez confidant to become the next mayor of Caracas, the South American nation's capital and largest city.

Chavez's brother, Adan, won a tight race to succeed their father as governor in the president's home state of Barinas.

Turnout topped 65 percent among the 16.8 million registered voters, a new high for a local election in Venezuela, Lucena said.

Chavez faced an emboldened opposition aiming to break his party's near total control over local offices and win back power in key states and cities.

Although Chavez held on to a majority of posts, the results of Sunday's vote could force him to cooperate with political rivals.

Ledezma called for cooperation between Chavez's government and opposition mayors, saying "I invite the president of the republic to work together to rescue Caracas" — a city blighted by crime, trash and crumbling infrastructure.

A similar invitation was offered by Henrique Capriles, who defeated one of Chavez's closest confidants to become the next governor of Miranda state, which includes part of Caracas.

"What's important is that the map of Venezuela has started to change," said opposition leader Manuel Rosales, calling the victories important gains for the anti-Chavez camp.

Chavez party spokesman Alberto Muller played down the opposition victories.

"We are the country's foremost political force," said Muller, flanked by other red-clad Chavez allies. "We don't see an opposition victory on a political map painted red."

In 2004 state elections, Chavez allies swept all but two of 23 governorships and a majority of local offices. In this vote, 22 governorships, 330 mayoral posts and other offices were up for grabs.

After a decade in office, the president still enjoys solid popularity, but last year's defeat of his attempt to abolish term limits energized the opposition, which has also sought to capitalize on complaints about unchecked corruption, rising crime, deteriorating public services and double-digit inflation.

At least 106 people were detained by authorities during the vote, many for destroying balloting materials such as voter receipts, the attorney general's office said. Six were arrested in Guarico state for allegedly attacking voters.

One person also was stabbed in a clash between government supporters and opponents in Bolivar state, but authorities said the vote largely went smoothly.