Indonesia is on high alert after a wave of recent bombings in the country's second-largest city, Surabaya.
The spate of attacks by militants left at least 28 people dead with dozens more injured.
The four swordsmen and their driver rammed a minivan into a gate at the Riau Police Headquarters in Pekanbaru to carry out the latest in a spate of militant attacks in the Muslim-majority country. Another police officer and a journalist were also wounded in the sword attack.
"When the vehicle broke through into the Riau police headquarters, it was blocked by policemen", police spokesman Setyo Wasisto told reporters.
Australian news website news.com.au reports that more than one reporter, attending an unrelated news conference, were hurt.
Then on Monday in Surabaya, a family of five targeted a police station - four of them were killed but an eight-year-old girl survived.
Following the 2002 Bali bombings, it had been widely praised for its sustained anti-terrorism crackdown.
It comes after a series of suicide attacks carried out by families that have shocked the country.
All six bombers died, including the mother who was Indonesia's first known female suicide bomber.
"My sister was always caring towards other people and taught her children to be compassionate", Daud Samari, Djumani's younger brother, told reporters.
"They had the same teacher and they regularly met for Koran recital every week", said East Java police chief Machfud Arifin.
Adjunct Senior Commissioner Sunarto, spokesman of the Riau Provincial Police, informed the press here on Wednesday that the four were shot dead after getting out of a minivan earlier used to attack police officers. The key figure in the attacks was the head of the Surabaya cell of a network of Indonesian extremists who have aligned themselves with IS.
"They were better organized ..."
Four of the men involved in the attack had previously tried to help terror detainees who were rioting at a maximum-security police lock-up outside Jakarta last week, he said.
"The one who escaped has been captured and secured at Pekanbaru police station", he said.