Police surrounded the bank before overpowering the gunmen
Fresh violence has erupted in the Afghan capital, Kabul, on the eve of the country's presidential election.
Explosions and gunfire were heard as troops battled and killed three attackers who raided a bank close to the presidential compound.
The Taliban have vowed to disrupt the election and said they were behind the raid, but this could not be confirmed.
The government has asked the media not to report violence on election day to avoid deterring people from voting.
But the move has been heavily criticised, and journalists said they would ignore it.
"It is a democratic day, a very important day for our independence, [and] this type of ban does not sit well with democratic principles," Rahimullah Samander, president of the Afghanistan Independent Journalists' Association, told AFP news agency.
Aid can make a huge difference in Afghanistan - but it has to be well-spent
On Tuesday more than 20 people were killed in attacks across the country, including a suicide blast in Kabul.
Meanwhile local officials in the central Ghazni province said that international forces had mistakenly killed four Afghan police overnight near the town of the same name.
The governor of Ghazni, Mohammad Osman Osmani, said other police were wounded in the attack, which was aimed at insurgents in the area who had been carrying out rocket attacks on the town.
In the northern Kunduz province, local officials told the BBC that two police had been killed and eight taken by the Taliban, although some of the eight may have already been working for the insurgents.
In Wednesday's attack, armed police forced their way into a central Kabul branch of the Pashtany bank after it was stormed by at least three gunmen.
They were then seen dragging at least three bodies out, and appeared to be in control of the building.
The Taliban have vowed to disrupt the elections on Thursday
The Afghan Interior Ministry said the raid had been carried out by "terrorists", although it had earlier described them as "robbers" or "thieves".
The presidential election on Thursday will be the second since the overthrow of the Taliban in 2001.
Hamid Karzai is tipped to be re-elected president in Thursday's polls, although correspondents say he could face a run-off against one of his strongest challengers, ex-Foreign Minister Abdullah Abdullah. Several dozen candidates are in the race.
The Taliban says they will use violence to disrupt the poll, prompting the Afghan government to call for a media blackout on any attacks from 0600 to 2000 on polling day.
"All domestic and international media agencies are requested to refrain from broadcasting any incident of violence during the election process from 6am to 8pm on 20 August," the foreign ministry said in a statement.
Siamak Herawi, a spokesman for President Karzai, said the blackout would prevent the media from having a "negative impact".
"If something happens, this will prevent them from exaggerating it, so that people will not be frightened to come out and vote."
But journalists and activists said Afghans had a right to know about the security threats they faced.
Mr Samander, of the Afghan Independent Journalists' Association, told Reuters news agency: "We condemn such moves to deprive people from accessing news."
Afghanistan's media has flourished in the last eight years
The New York-based organisation Human Rights Watch, called the government's position an "unreasonable violation of press freedoms".
Aid agency Oxfam also delivered a clear warning on the eve of polling, saying that the elections must be accompanied by major reforms in governance and aid if Afghanistan is to prosper.
Oxfam said that, despite massive investment, one-third of Afghans still faced hunger and poverty.
The organisation said that billions of dollars of aid have been channelled into Afghanistan by foreign governments since 2001, but these have been "woefully insufficient" to deal with the legacy of three decades of conflict.
Too few Afghans were benefiting from the money and much of it had been "ineffective, unco-ordinated or wasteful", Oxfam said.
The group said the election of a new government had to be accompanied by major reforms. "Aid can make a huge difference in Afghanistan - but it has to be well-spent," it said.
This page is best viewed in an up-to-date web browser with style sheets (CSS) enabled. While you will be able to view the content of this page in your current browser, you will not be able to get the full visual experience. Please consider upgrading your browser software or enabling style sheets (CSS) if you are able to do so.