A Russian military court has sentenced a soldier to life in prison for killing a family of seven outside a military base in Armenia.

The court at the Russian base in the Armenian city of Gyumri on Tuesday found Valery Permyakov guilty of killing the family after he left his base with a machine gun and went on a shooting rampage at their home, killing all of them including a 6-month-old infant.

Russia is Armenia's main sponsor and ally and has troops stationed there. The brutal killing sparked protests in the otherwise Russia-friendly Armenia as residents feared the supposed killer would be sent home.

Permyakov was reported to have confessed to the killing earlier in the trial but refused to give testimony.