The attack occurred in the village of Kizlyar in the Muslim-majority republic of Dagestan, agencies said.
The small republic in the Caucasus mountains borders Chechnya, where Moscow has led two wars against separatists and radical religious groups since the 1991 Soviet collapse and which has seen a large number of people join Daesh.
Russian news agencies said the attack occurred as churchgoers celebrated Maslenitsa, a Christian holiday marking the last day before Lent according to the eastern Orthodox calendar.
The assailant was identified as a 22-year-old man local to the region, the TASS news agency said, citing the investigative committee.
He was shot and killed by security services who were on duty nearby, TASS said, adding that a hunting rifle, bullets and a knife were discovered on his person.
Initial reports suggested all five victims were women, TASS said, citing the local branch of the interior ministry.
The injured include two members of local security services and two civilians, also women, the Interfax news agency said.