The shooting at the base in the Puli Khumri district of Baghlan province occurred as troops carried out maintenance on a vehicle, the NATO-led International Security Assistance Force (ISAF) said.
A man in Afghan uniform shot at the troops and they fired back, critically injuring the gunman.
German Defence Minister Karl-Theodor zu Guttenberg earlier said in Berlin two German soldiers were killed and seven other injured, three of them seriously.
A third soldier, 21, died later of his injuries, a spokesman for the German army said. The other fatalities were aged 22 and 30 and their families have been informed, the German army said on its website.
The deaths brought to 48 the number of German soldiers killed in Afghanistan since the end of 2001.
Giving details of the incident, ISAF said: "An individual wearing an Afghan National Army uniform fired at International Security Assistance Forces working on a vehicle in northern Afghanistan today."
There are around 5,000 German troops serving in Afghanistan as part of a US-led NATO force of 140,000, a mission that is unpopular among many Germans.
The deaths came the day after zu Guttenberg visited his country`s troops in Afghanistan.
The minister is embroiled in a scandal at home, where has just given up his doctoral title pending an investigation into claims that he plagiarised large parts of his thesis.(*)
Editor: Ruslan Burhani
Copyright © ANTARA 2011