KABUL, Afghanistan — For the two seasoned war correspondents, it was not an unusually risky trip. Getting out to see Afghanistan up close was what Anja Niedringhaus, a Pulitzer Prize-winning photographer for The Associated Press, and Kathy Gannon, a veteran reporter for the news agency, did best.

The eastern province of Khost, where Ms. Niedringhaus and Ms. Gannon traveled to cover Afghanistan’s presidential election on Saturday, is considered dangerous, still plagued by regular Taliban attacks. But they had carefully plotted their trip, arranging to move beyond the relatively safe confines of the provincial capital under the protection of Afghan Army troops and the police.

Yet it was those precautions that proved fatal for Ms. Niedringhaus on Friday morning. As she and Ms. Gannon waited outside a government compound, a police commander walked up to their idling car, looked in at the two women in the back seat, and then shouted “Allahu akbar!” — God is great — and opened fire with an AK-47, witnesses and The Associated Press said.

Ms. Niedringhaus was killed instantly, and Ms. Gannon, shot three times in the wrist and shoulder, was severely wounded. In the span of a few muzzle flashes, the two women, who had covered the war since it began in 2001, became victims of another attack that blurred friend and foe.