Six people were reported wounded in the incident in northern Bangkok on the eve of an election that has left the country deeply divided.
On Saturday at 8.30pm the Election Commission (EC) announced that voting in Lak Si on Sunday would be cancelled.
The EC said it would not open 158 polling units in the district as offcials had failed in negotiations with protesters to obtain the ballots from the blockaded district office. A new election will be held later.
Saturday's clashes began shortly before 4pm when the sound of a bomb was heard. An hour later, witnesses reported noises that sounded like firecrackers, but which turned out to be hundreds of gunshots. The firing continued for nearly 30 minutes.
The Erawan Medical Centre said the six injured people, four men and two women, had been taken to hospital.
As the shooting intensified, people in the area ran to take shelter on a nearby covered pedestrian bridge, and in Lak Si Plaza and the IT Square mall.
Among the wounded was a Daily News reporter and an American photographer, James Nachtwey. Journalists wear light-green armbands for safety but the anti-government People's Democratic Reform Committee (PDRC) has adopted similar bands.
The Thai Journalists Association urged the PDRC to change its colours and end the confusion so reporters don't become targets.
Soldiers were reported to be moving into the area to help police control the situation. By around 6.30pm relative calm had been restored.
The clashes erupted after rival groups of demonstrators had taken up positions just 500 metres apart and some appeared to be spoiling for a fight.
Women and children were allowed to take shelter inside the blockaded Lak Si district office in case trouble broke out.
The anti-government protesters led by Luang Pu Buddha Issara surrounded the district office on Friday to stop it from being used as a polling station.
Luang Pu Buddha Issara asked officials to leave the office by noon as protesters would seal the premises and cut water and electricity until Sunday evening.
On the other side, around 200 red-shirt supporters of the United Front for Democracy against Dictatorship gathered at Lak Si temple, just 500 metres from the district office.
Ballot boxes and papers for other polling stations in Constituency 11 were also being stored at the office.
Election Commission officials and Pol Col Charoen Srisaluck, deputy superintendent of Metropolitan Police Division 2, went to negotiate with the PDRC in order to get into the district office and get the ballots. However, the talks were unsuccessful and EC officials left the office.
While voting on Sunday is expected to go ahead without incident in the northern and northeastern provinces loyal to the Pheu Thai Party, more disruptions are expected in Bangkok and the South.
PDRC leader Suthep Thaugsuban has said that members would not obstruct voting but some of its more radical followers disrupted many advance polls and forced their closure last Sunday.
Election officials are also having trouble getting into sites where ballots are stored in some areas of the South. As a result, voting could be affected in as many as 14 southern provinces.
The Democrat Party is boycotting Sunday's poll, which is costing taxpayers 3.8 billion baht and will not produce enough MPs to convene a sitting of the House of Representatives. That could take four to five more months of byelections to achieve.
A total of 130,000 police will be deployed at polling stations nationwide to maintain order during Sunday's election, according to Chalerm Yubamrung, the director of the Centre for Maintaining Peace and Order.
Twenty-seven companies of soldiers would also be deployed to help police ensure that people who want to vote can do so, he said.
Video clip is taken by Bangkok Post photographer Apichit Jinakul.