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.
Sidharth Malhotra and Rakul Preet Singh return from Bengaluru promotions of Aiyaary
This wasn't the only trouble Pandey had to deal with in relation to the films release. After Jai turns rogue a war is triggered between the master and the protege.
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.