Hiroo Onoda, an Imperial Japanese Army officer who remained at his jungle post on an island in the Philippines for 29 years, refusing to believe that World War II was over, and returned to a hero’s welcome in the all but unrecognizable Japan of 1974, died on Thursday in Tokyo. He was 91.

His death, at a hospital there, was announced by the Japanese government.

Caught in a time warp, Mr. Onoda, a second lieutenant, was one of the war’s last holdouts: a soldier who believed that the emperor was a deity and the war a sacred mission; who survived on bananas and coconuts and sometimes killed villagers he assumed were enemies; who finally went home to the lotus land of paper and wood which turned out to be a futuristic world of skyscrapers, television, jet planes and pollution and atomic destruction.

Japanese history and literature are replete with heroes who have remained loyal to a cause, especially if it is lost or hopeless, and Lieutenant Onoda, a small, wiry man of dignified manner and military bearing, seemed to many like a samurai of old, ultimately offering his sword as a gesture of surrender to President Ferdinand E. Marcos of the Philippines, who returned it to him.