Soldiers battled for three hours against a small band of anti-government fighters who snuck onto a Venezuelan army base, apparently intent on fomenting an uprising, President Nicolas Maduro said.

Troops killed two of the intruders, wounded another and captured seven, but 10 others got away, the embattled leader announced in his weekly broadcast on state television.

"We know where they are headed and all of our military and police force is deployed," Mr Maduro said. He said he would ask for "the maximum penalty for those who participated in this terrorist attack".

The incident happened during the early hours of Sunday morning at the Paramacay base in the central city of Valencia. Residents who live nearby said they heard repeated bursts of gunfire starting around 4.30am.

A video showing more than a dozen men dressed in military fatigues, some carrying rifles, began circulating widely on social media around that time. In the recording, a man who identified himself as Captain Juan Caguaripano said the men were members of the military who oppose Mr Maduro's socialist government and called on military units to declare themselves in open rebellion.

"This is not a coup d'etat," the man said. "This is a civic and military action to re-establish the constitutional order."

Twenty men entered the base, catching soldiers on night watch by surprise, Mr Maduro said. The intruders managed to reach the base's weapons depot before an alarm sounded, alerting troops to the incursion.

He said 10 of the invaders then escaped, some carrying off arms, while those left behind exchanged gunfire with soldiers until about 8am before all were either killed or captured.

"Today we had to defeat terrorism with bullets," Mr Maduro said.

Residents who live nearby and saw the dissident group's video online gathered around the military base chanting "Freedom!" Other protests also emerged spontaneously around Valencia into the afternoon.

Troops dispersed the protesters with tear gas and a man was fatally shot at a demonstration less than a mile from the base, said Haydee Franco, coordinating secretary of the Progressive Advance party. More than 120 people have been reported killed in unrest that began in early April.

Defence Minister Vladimir Padrino Lopez characterised the attackers as a "paramilitary" expedition, saying the intruders were civilians dressed in uniforms.

He did not identify any of the participants, but said they included a lieutenant who had abandoned his post. He said the man who recorded the video was a former officer dismissed three years ago after being charged with rebellion and betraying the homeland.

In 2014, Mr Caguaripano released a 12-minute video denouncing Mr Maduro during a previous wave of anti-government unrest. He later reportedly sought exile after a military tribunal ordered his arrest, appearing in an interview on CNN en Espanol to draw attention to what he said was discontent within military ranks.

He returned to Venezuela to lead Sunday's uprising, said Giomar Flores, a mutinous naval officer now in Bogota, Colombia, who said he is a spokesman for the group.

Mr Padrino Lopez alleged the attackers were recruited by "right-wing extremists" working with unspecified foreign governments. Mr Maduro said the attack was "paid for by Miami and Colombia" — cities with large numbers of Venezuelans who oppose his government. Neither provided specific details on how they had come to that conclusion.

"Today's terrorist attack is no more than a propaganda show," Mr Padrino Lopez said.

Venezuela's latest bout of political unrest erupted in protest to a Supreme Court decision in late March ordering the opposition-controlled National Assembly dissolved. Although the order was quickly annulled, near-daily demonstrations snowballed into a general protest calling for a new presidential election.

Opposition leaders have urged the military, which historically has served as an arbiter of Venezuela's political disputes, to break with Mr Maduro over what his foes consider violations of the constitution.

But the president is believed to still have the military's support. He and his predecessor, the late President Hugo Chavez, worked diligently to assure their allegiance.

Like Sunday's uprising, most manifestations of dissent among troops have been small and isolated thus far.

"It's still very hard to know to what extent there are significant divisions within the military," Michael Shifter, president of the Washington-based Inter-American Dialogue, said recently.

The attack capped an already tense weekend during which a new constitutional assembly that will rule with nearly unlimited powers voted to remove chief prosecutor Luisa Ortega Diaz.

Ms Ortega Diaz, a longtime government loyalist who has become one of Mr Maduro's most outspoken critics, reiterated her refusal to recognise that decision at a public appearance alongside opposition leaders on Sunday.

"I am still Venezuela's chief prosecutor," she said to applause.

The assembly ordered her replaced by Ombudsman Tarek William Saab, who was recently sanctioned by Washington for failing to protect protesters from abuses in his role as the nation's top human rights official.

Meanwhile, jailed opposition leader Leopoldo Lopez was returned home to serve out under house arrest his 13-year sentence for inciting violence at 2014 protests. He had been hauled back to prison in the middle of the night a few days earlier in a move that drew international condemnation.

Mr Lopez's wife, Lilian Tintori, said in a message on Twitter that she and her husband remained committed to achieving "peace and freedom for Venezuela".