* Ghani not in building, but family members at home
* Taliban claims responsibility
* Kabul on high alert ahead of April 5 election
By Hamid Shalizi and Maria Golovnina
KABUL, March 25 (Reuters) - Suicide bombers and gunmen in Afghanistan attacked an election commission office beside the home of presidential candidate Ashraf Ghani on Tuesday, rattling nerves in the Afghan capital less than two weeks before a crucial election.
Kabul is on high alert ahead of the April 5 presidential vote that Taliban insurgents have threatened to derail through a campaign of bombings and assassinations.
Ghani, a former World Bank official and frontrunner in the vote, was not at home at the time of the attack, for which the Taliban took responsibility.
Security forces cordoned off the area in western Kabul and besieged the building for several hours as militants returned fire from their positions.
"The operation is over," the deputy interior minister, General Ayoub Salangi, told Reuters. "Five enemies were killed and all election workers trapped inside were rescued."
Two policemen, an election worker and a provincial council candidate were killed, a spokesman for the interior ministry said.
Security is tight in Kabul ahead of the election, which is designed to mark Afghanistan's first democratic transfer of power. Nine people were killed last week in a brazen attack on a luxury hotel in the capital.
The rise in violence has fuelled nervousness in Kabul ahead of the vote.
The United Nations, which is advising Afghan election officials, told staff in a security note to exercise caution and only authorise essential programs.
President Hamid Karzai is barred from running for another term after 12 years in power but is widely expected to retain his influence.
Police initially said militants had attacked Ghani's house itself but later Ghani's campaign aide said the assault targeted an adjacent building.
"The attack was on an election office next to Dr Ashraf Ghani's house," said the aide. "His house was also hit by the attackers."
Ghani, in a Twitter post after the attack, said: "Just arrived at Gardez rally, a huge crowd of tens of thousands." Gardez is in a volatile area south of Kabul.
Later, he added: "Terrorists cannot deter us from our cause with their cowardly attacks. My family is safe. Thank you to those of you who prayed for us."
How the election unfolds will be a pointer to prospects for stability in Afghanistan as the NATO-led force, which has been reinforcing security since the Taliban were driven from power in 2001, prepares to pull out most troops this year.
The Islamist Taliban movement has ordered its fighters to go all out to disrupt the vote and threatened to kill anyone who takes part in what it calls a Western-backed sham.
Voters in Afghanistan are used to almost daily attacks and few have raised the prospect of the vote being derailed altogether. But any noticeable increase in violence would be enough to scare people away from polling stations.
"There was some speculation about what their attitude would be during the election ... whether they were just threatening, or would really execute this threat," said one Western diplomat.
"It turns out they have really decided to implement this threat."
The Taliban said in a statement their suicide bombers had entered the building and blown themselves up.
"A number of suicide bombers attacked an important election centre at the heart of Kabul," the movement said. "The attack started with a very heavy explosion and then a number of people entered with heavy and light weapons."
Separately on Tuesday, three suicide bombers entered a branch of Kabulbank, one of Afghanistan's biggest banks, in the eastern province of Kunar, killing at least three security guards and injuring two bank workers, police said.
In the southern province of Helmand, a gunman killed a policewoman, police said. (Additional reporting by Mirwais Harooni and Jessica Donati; Writing by Maria Golovnina; Editing by Clarence Fernandez)
Our Standards: The Thomson Reuters Trust Principles.