The shooting happened Monday in front of the main gate of the base in the Helmand province. Authorities said the Afghan soldier arrived at the base in an army vehicle.
The gunman claimed he had been assigned to provide security for a delegation of government officials from Kabul visiting the base.
Once he got inside, the suspect opened fire, killing two British soldiers. Coalition forces returned fire and killed him. Authorities said the gunman is from an eastern Afghan province and had been in the army for four years.
Such attacks have become increasingly common over the past year, particularly since the burning of Qurans at a U.S. base in February. Fifteen NATO service members, including eight Americans, have been killed by Afghan security officials or militants disguised in their uniforms so far this year.
Monday's attack also comes two weeks after a U.S. soldier allegedly went on a shooting rampage that killed 17 Afghan villagers and wounded six.
The Associated Press contributed to this report.