KABUL—An Afghan soldier killed a two-star U.S. Army general when he opened fire on a group of Western military officers Tuesday, officials said, claiming the highest-ranking American casualty in more than a decade of war and resurrecting concerns about the U.S. exit strategy from Afghanistan.

The attacker, armed with a machine gun and wearing an Afghan army uniform, surprised the visiting group of Western military officials and fired...