Image copyright Reuters

Two Americans have been killed and a further three have been injured after a gunman opened fire on a military base in Kabul, Afghanistan, officials say.

A service member and a civilian were killed in the attack, which Afghan officials are calling an "insider" job.

Two civilians and a service member are in a stable condition, a Nato military alliance statement said.

The gunman has been killed. No insurgent group has so far claimed responsibility for the attack.

The Americans were said to be conducting duties as part of their mission to train, advise and assist Afghan forces when they came under attack.

"Anytime we lose a member of our team, it is deeply painful," said General John Nicholson, the top US and Nato commander in Afghanistan. "Our sympathies go out to the families, loved ones, and the units of those involved in this incident."

Dawlat Waziri, a spokesman for the Afghan defence ministry, said the ministry had launched an investigation into the incident.

The US ended major combat operations in Afghanistan at the end of 2014.

There are currently about 9,000 US soldiers in the country, with a mission to train Afghan forces and support operations against the Taliban and other militant groups.

US troops were to be reduced to 5,500, but President Barack Obama subsequently announced a slowdown in the US military withdrawal in July, saying 8,400 soldiers would stay there into next year.