The formal surrender of Japan was held in Tokyo Bay on Sept. 2, 1945 — weeks after two atomic bomb blasts brought an end to years of carnage. Emperor Hirohito had called on Japanese to “endure the unendurable,” forfeiting the cause that led millions of his countrymen to their graves.

World War II was over, but not for Hiroo Onoda. A lieutenant in the Imperial Japanese army, Onoda spent another 29 years hiding in the jungle of an isolated Philippine island.

The Japanese government spent a small fortune trying to alert stragglers like Mr. Onoda about the war’s end, but he dismissed it as enemy propaganda. He stuck to his gun and headed back into the bush in the service of his emperor, bracing for an enemy that didn’t exist anymore.

For Onoda, who continued beyond belief to follow wartime orders, loyalty was not only blind but deaf.

He emerged in 1974, emaciated but still sporting what remained of his old uniform. Onoda, who died Thursday at age 91, was the last Japanese soldier to come out of hiding in the Philippines, having survived on thievery, asceticism and undeviating will. Onoda said he thought of “nothing but accomplishing my duty.”

To many Japanese at the time, he embodied pre-war virtues of endurance, obedience and sacrifice — qualities increasingly antiquated as the country transformed from the devastation of war into an economic powerhouse and a hive of materialism.

At the time of Onoda’s surrender, the Japanese ambassador to the Philippines declared him the “paragon of the Japanese soldier.”

Other Japanese soldiers from World War II lived on for decades, guerrilla-style recluses in the jungles of Guam and Indonesia, but Onoda stirred the deepest emotional and nostalgic response. Where other army stragglers stayed hidden reputedly out of fear of execution, Onoda remained committed to his mission of counting American bombers.

His orders: “To continue carrying out your mission even after the Japanese Army surrenders, no matter what happens.”

The cost was extreme. When he left the jungle at long last, he met a world where Richard Nixon was the U.S. president, where the Cold War and the nuclear age dominated politics, where skyscrapers towered, and where television was inescapable. He did not marvel at the small-screen technology, noting that it “irritates my eyes.”

If he seemed lost in the new world, some circumstances of his youth seemed to have remained the same. He said he was restless when he returned at last to his home region in central Japan and settled in with his octogenarian parents who had long believed him dead. He did not get along with them when he was a teenager and time had not changed a thing, he said. He soon returned to isolation, only this time as a rancher in Brazil.

Onoda died at a hospital in Tokyo, the government announced. No cause was reported.