MANILA — A Dutch hostage held by Muslim militants in the southern Philippines for seven years was killed by his captors on Friday as he tried to escape during a bloody rescue attempt by the military, officials said.

The hostage, Ewold Horn, 59, had been seized along with a Swiss national while the two were bird watching on the remote southern island of Tawi-Tawi in 2012. They were taken by Abu Sayyaf militants across the strait to Jolo, an island where the gunmen are well entrenched, with their camps situated deep inside nearly impenetrable jungle terrain.

The Swiss hostage, Lorenzo Vinciguerra, managed to escape nearly three years later by grabbing his guard’s knife and stabbing him in the neck as the militants came under attack from military forces. He then fled his captors and was rescued by the army.

But Mr. Horn was not so lucky.

“What a pity. He nearly escaped, but was shot,” said Col. Gerry Besana, a spokesman for the military’s Western Mindanao Command. “He was shot by his guards while trying to escape amid the firefight.”