A Russian soldier has killed four people in a rampage targeting his own colleagues before turning his gun on civilians.

Four others have been wounded in the attack at the naval port of Sevastopol in occupied Crimea.

The soldier, believed to be Maxim Alistratov, 21, from Saratov, initially opened fire on soldiers, shooting one dead and wounding another, authorities said.

Alistratov, named by media outlets close to the Russian regime in Crimea, then began attacking civilians, killing two men and one woman and wounding another three.

The attacker was subsequently detained.