National Police spokesman Muhammad Iqbal said the man in Wednesday's attack at the Medan city police station passed through a guard post and into the station's yard, which was packed with people who were lining up to get various police certificates.
The attacker detonated his explosives and died near a parking lot after being confronted by other officers, wounding at least four police and two civilians, Iqbal said. They were rushed to a nearby police hospital, most with minor injuries.
Another police spokesman, Dedi Prasetyo, told a news conference later that the attacker, identified as Rabbial Muslim Nasution, seemed to be trying to reach a canteen where police and civilians were having coffee or breakfast, but his explosives detonated prematurely.
Prasetyo said that security procedures had been in place for accepting visitors to the police station. Prasetyo said the attacker told officers he was at the station to get a background check certificate he needed to apply for a job.
He said the attacker managed to pass police twice checking his backpack, which only contained books, and had opened his jacket to be checked. He said the explosives must have been under his shirt. He said that police were still investigating whether the 24-year-old university student was linked to a local affiliate of the Islamic State group known as the Jemaah Anshorut Daulah or was just an independent attacker.
A security camera video of the attack showed the attacker wearing a backpack and a jacket of a local ride-hailing service walking near a parking lot and then an explosion. The attack came as Indonesia's counterterrorism force worked to root out suspected Islamic militants following last month's assault by a knife-wielding militant couple who wounded Indonesia's top security minister.
More than 40 suspects have been detained by the counterterrorism squad, known as Densus 88, in several provinces, including ones captured on Tuesday, Prasetyo said. The sweep followed a tipoff about possible attacks against police and places of worship in several areas.
President Joko Widodo condemned Wednesday's attack and said the government would not tolerate any kind of terrorism. "The perpetrators or terrorist groups will continue to be pursued, arrested and tried, and the government will guarantee the best possible security protection to all people," Widodo said in a statement.
Indonesia, the world's most populous Muslim-majority nation, has been battling militants since bombings on the resort island of Bali in 2002 killed 202 people, mostly foreign tourists. Attacks aimed at foreigners have been largely replaced in recent years by smaller, less deadly strikes targeting the government, mainly police and anti-terrorism forces and local "infidels."
In May last year, two families carried out suicide bombings at churches in Indonesia's second-largest city, Surabaya, killing a dozen people.