The shooting took place on Sunday evening in Kizlyar, a town of about 50,000 people on the border with Chechnya.
"The killed shooter was identified as Khalil Khalilov, 22, a resident of Rassvet village of Dagestan's Tarumovsky District", the statement, published on the town administration's website, read. The local Interior Ministry, however, said the gunman had acted on his own, according to the Interfax news agency.
The Russian RBK daily quoted an Orthodox priest saying the attacker had opened fire on churchgoers following an afternoon service.
Four women were killed on the site of the incident, while another woman subsequently succumbed to her wounds in hospital, the document added.
The gunman targeted worshippers at a Russian Orthodox church in the mainly Muslim region, although no motive has been established yet.
José Mourinho calls rumours of Paul Pogba rift 'lies'
French newspaper L'Equipe claim Pogba is unhappy with the more defensive role has been asked to perform by Mourinho recently. The youngster has featured 14 times for the club after making his debut towards the end of last season.
Next to his corpse lay two of his victims, covered in a white shroud.
Islamic State claimed responsibility for the shooting, its news agency Amaq reported, but did not provide immediate evidence for the claim.
In 2015, ISIS declared it had established a "franchise" in the North Caucasus.
Sunday's shooting comes exactly one month before the March 18 presidential election that Vladimir Putin is nearly guaranteed to win.
It has been the scene of an Islamist insurgency following separatist wars in the neighbouring Chechnya.