A roadside bomb has killed a prosecutor near the town of Buynaksk in the southern Russian republic of Dagestan.
The prosecutor, Bitar Bitarov, died in hospital from his wounds.
An hour after the attack, when Dagestan's interior minister approached the town to investigate, his motorcade came under fire.
An exchange of fire followed between police accompanying the minister and the gunmen, in which two policemen were fatally injured.
Interior Minister Adilgerei Magomedtagirov was not hurt.
Dagestan authorities suggested that there was a link between the attack on the prosecutor, who was killed by a bomb on his way to work, and the ambush of the minister.
"It's perfectly possible that they laid this ambush, knowing that the minister was going to the scene," said a ministry spokeswoman, quoted by the Associated Press news agency.
Special forces and interior ministry troops went to the scene of the second attack and searched the area, Russian media report.
The high level of violence in the North Caucasus republic is often associated with organised crime or political in-fighting. But some may be linked to the separatist conflict in neighbouring Chechnya, correspondents say.