Islamic State said its fighters were behind the attack.
The police stormed an apartment in the southern town of Derbent after obtaining information that a wounded senior officer held hostage by the militants was probably dead.
"Law enforcers have finished a special operation to destroy the rebels," Interfax news agency quoted a police source as saying. "At least four rebels have been annihilated."
One police officer was killed in the shootout and another 15 were wounded, a local health official told Russian agencies. The senior officer who had been held was confirmed dead by a police official, Interfax news agency said.
Islamic State's Amaq news agency said its fighters had clashed with police in Derbent, saying they had killed three officers. It made no mention of losses among the militants.
Islamic State has in the past said it was behind violent attacks on security forces in the North Caucasus, the volatile mainly Muslim part of Russia where Dagestan is located.
Some militants in Dagestan, which borders Chechnya, where Moscow led two wars against separatists in 1990s, have sworn allegiance to Islamic State.