Congress in the Dominican Republic was thrown into chaos as the lights failed and gunshots rang out during a session to elect a new speaker.
Police rushed to guard the Congress building
No one was injured but deputies dived under tables or fled in panic, while others used their mobile phones to alert the police when the shooting erupted amid the darkness.
It is not yet clear who fired the shots nor what caused the blackout.
The election went ahead by torchlight but opposition deputies say the poll was illegal and have said they will appeal to the Supreme Court on Monday.
The country's constitution requires the election for speaker to take place on 16 August each year.
This year's vote was won by Alfredo Pacheco of the governing Dominican Revolutionary Party (PRD) who had earlier spoken of receiving death threats. He blamed an internal party power struggle for the shooting.
Correspondents say the PRD is deeply divided between those who back the re-election of President Hipolito Mejia in next year's election and those, like Mr Pacheco, who are opposed to his candidacy.
Several members of the opposition were not present when the vote took place and denounced the result.
Sporting success not political tension made the headlines
Although power cuts are frequent in the Dominican Republic, the electricity company, Edesur, denied any responsibility for Saturday's incident which only knocked out lights in the House of Representatives.
The shooting came as most Dominicans were preoccupied with the Pan American Games being held in their country.
The event, which concludes on Sunday, has been largely successful, despite fears that power cuts would disrupt competition.