At least three people were killed when a suicide bomber blew himself up and militants opened fire in a court complex in northwest Pakistan on Monday, officials said.
Several gunmen and the bomber stormed the crowded complex in the city of Peshawar, less than two months before expected national elections.
"One suicide bomber blew himself up in the court of an additional sessions judge. The other was shot dead by police," said senior police officer Masood Khan Afridi.
"It was an act of terrorism and the target was the judicial complex. Three civilians were killed and 30 people wounded, four of them police officials," he added.
"We have cleared the whole area and a combing operation is continuing."
Afridi denied reports that some judges and lawyers were being held hostage inside the courts. "There are no hostages, I have just come back from the site of the attack," he said.
The exact death toll was unclear. Sayed Jameel Shah, a spokesman for Peshawar's main Lady Reading Hospital, said the hospital had received four bodies and was treating 25 injured people.
The nuclear-armed country of 180 million is due to elect new leaders by mid-May. But Taliban attacks and record levels of violence against the Shiite Muslim minority have raised fears about security for the polls.
"Terrorists have attacked at a time when general elections are very near and the atmosphere for election is smooth," said the information minister for Khyber Pakhtunkhwa province, Mian Iftikhar Hussain.
"It could be an attempt to disturb the peaceful atmosphere but elections should never be postponed."
Pakistan's Prime Minister Raja Pervez Ashraf on Saturday hailed parliament's historic completion of a full term in office as a victory for democracy as he gave his farewell address to the nation.
The polling date has yet to be announced but officials say the Election Commission has recommended May 8, 9 or 10.
The attack is the second in Peshawar in less than a month. Militants including a suicide bomber attacked the office of a senior official there on February 18, killing six people.
The heavily-guarded court complex is in front of a five-star hotel and close to government and official buildings.
Khyber, part of Pakistan's semi-autonomous tribal belt on the Afghan border, is in the grip of intensified fighting as part of a long-running military operation against the Taliban and other Islamist insurgents.