The Ministry of Defence said Mr Spencer was a lance corporal in the 3rd Battalion The Rifles.
The light infantry battalion is based in Dreghorn Barracks in Edinburgh.
Defence Minister Mark Lancaster said: “It is with deep sadness that I can confirm that Lance Corporal Joe Spencer from 3rd Battalion The Rifles died at RAF Tain on Tuesday.
“My thoughts are with Joe’s family, friends and colleagues at this terrible time.
“We are co-operating with the police investigation and looking into the circumstances surrounding this tragic incident.”
The Tain training facility is used by the RAF and the Army.
It has a rifle range, a small arms range as well as bombing ranges.