Television footage of the attack showed a panicked crowd running and screaming while gunshots were heard. Some people sought refuge in a nearby church.
The armed assault occurred in Catia, a working class neighborhood in the capital Caracas. Prosecutors said in a statement an investigation had been opened.
The opposition coalition blamed the attack on "paramilitary groups" linked to Maduro's government.
The violence confirmed fears surrounding an electoral tussle between the opposition and Maduro, focused on the beleaguered president's bid to rewrite the constitution.
It also fed into nearly four months of protests during which nearly 100 people have died.
Hundreds of thousands of Venezuelans cast ballots on Sunday in the vote aimed at rejecting Maduro's plans to have a citizens' body elected on July 30 to carry out the constitutional do-over.
The call to polls was described as a "plebiscite" by the opposition, but the government slammed it as "illegal".
To detract from the opposition vote, Maduro's government held a dry-run simulation the same day of the election to be held at the end of the month.
Several Latin American countries and the Catholic Church have criticized the move to draw up a new constitution, which the opposition says is a bid by Maduro to concentrate dictatorial powers to stay in power.
Voters wearing white or the colors of the Venezuelan flag lined up in front of the 14,000 makeshift polling tables set up under tents across the country by the opposition.
"We are turning out to show our discontent with the government," 49-year-old Tibisay Mendez said in Caracas.
"We can't find medicines, every day there is less food in the country. And they (Maduro and his officials) only want to hold on to power. We are voting to get them out," she said.
'Win back democracy'
Voters were asked if they rejected Maduro's plan to create a "Constituent Assembly" to redo the constitution, and if they approved of early elections.
Julio Borges, leader of the opposition-controlled parliament, said the vote was a watershed moment "in this fight to win back democracy for Venezuela."
But Hector Rodriguez, chief of the ruling party bloc in parliament, contrasted the opposition vote and the government simulation as "a choice between violent protests and peace."
Both the opposition and the government have dug in on their respective courses. Attempts at dialogue have failed, and now each is talking to the public at cross-purposes.Meanwhile the population is suffering a crushing economic crisis, with shortages of food and medicine and triple-digit inflation.
Opposition leader Henrique Capriles votes at a symbolic referendum in Caracas, Venezuela. Source: AAP
The opposition accuses Maduro of driving the country into bankruptcy, and of using the Constituent Assembly to entirely sideline the parliament.
The president, in turn, says the opposition is collaborating with the "imperialist" United States to undermine the economy, and to topple his government.
He has presented his proposed 545-member Constituent Assembly, drawn from various sectors of society, as "the only path" to peace and economic recovery.
Although he is deeply unpopular - the Datanalisis polling firm says 80 percent of Venezuelans reject Maduro as leader - he retains the loyalty of military chiefs, and can count on the support of electoral authorities and judges.
'No-one wants him'
But some cracks are appearing in his camp. The most stark was the rebellion of Attorney General Luisa Ortega, who came out against the Constituent Assembly. She holds onto her office, for now, remaining a potent voice of dissent in government.
According to Datanalisis, 70 percent of voters taking part in Sunday's consultation are expected to reject the Constituent Assembly. It expects participation to reach 10.5 million people -- a majority of Venezuela's 19 million voters.
A result was expected late Sunday, Venezuela time.
To add legitimacy to the process, the opposition invited five former Latin American leaders to act as observers.
"Maduro needs to understand that no-one wants him. He needs to leave now, that's all," one of them, former Mexican president Vicente Fox, said.