The gunman who killed four people in Tanzania's financial capital Dar es Salaam last week before being shot dead was "a terrorist" who became radicalised through the internet, police said Thursday.
The assailant -- identified by police as Hamza Mohamed -- went on a rampage on August 25, killing three officers and a private security guard in the city's diplomatic quarter, in a rare attack in the East African nation.
"Our investigations have revealed that Hamza Mohamed was a person who had a secret life with all indicators of terrorism," the director of criminal investigations, Camillus Wambura, told journalists.
Wambura described the man as "a terrorist."
"He spent much of his time to learn about the kinds of terrorism incidents such as those conducted by Al-Shabaab and ISIS through the internet, like many terrorists do," Wambura said.
In addition to the four dead, six other people were injured in the shooting spree, which took place near the entrance of the French embassy.
Footage aired on local media showed a man in a checked shirt and white Islamic cap armed with an assault rifle roaming the street near a city bus.
"The man appeared like a sheikh with a white cap. He passed near me without greeting and when I greeted him he did not reply. He was sweating. After a short while, we heard firing," said one witness who declined to be named.
Dozens of police officers, politicians and Tanzanian citizens gathered on Friday at a ceremony to pay their last respects to the slain officers and eulogise them.
"If the parents did their responsibility, what Hamza did could not have happened," police chief Simon Sirro told mourners.
Neighbours have expressed shock at the shooting, saying the attacker lived with his mother in a flat about two kilometres (just over over one mile) from where the incident took place.
"I knew him since he was a young boy. There was a time he disappeared until he came back recently," taxi driver Omary Issa said.
"He was an ordinary person whom we interacted like any other neighbour. I was really shocked," he added.
The shooting took place shortly after President Samia Suluhu Hassan hosted a meeting in Dar es Salaam of senior officers.
Hassan expressed her condolences, as did the US ambassador to Tanzania, Donald Wright, who called the attack "senseless" and tweeted his "deepest thanks to the brave law enforcement personnel who brought an end to the rampage."
Such attacks are relatively rare in Tanzania, which has been largely peaceful in contrast to its volatile neighbours such as Mozambique.
Jihadists have been battering Mozambique's gas-rich Cabo Delgado province since 2017, killing more than 1,300 civilians and prompting hundreds of thousands of people to flee.
Known locally as Al-Shabaab -- but with no relation to the Somali group of the same name -- the IS-linked militants have conducted several brazen raids on towns and villages in an apparent bid to establish an Islamic caliphate.
In October, about 300 jihadists from the IS-affiliated Islamic State Central Africa Province (ISCAP) attacked a police station in Mtwara near the Mozambican border, Tanzanian officials said.
The Islamists have carried out a string of small-scale attacks in Tanzania, including targeted killings of police and administrative officials in the eastern district of Kibiti in 2016 and 2017.