On the path to Mordor, stronghold of Sauron, the Dark Lord, the air is “filled with a bitter reek that caught their breath and parched their mouths.” Tolkien later acknowledged that the Dead Marshes, with their pools of muck and floating corpses, “owe something to Northern France after the Battle of the Somme.”

In a lecture delivered in 1939, “On Fairy-Stories,” Tolkien explained that his youthful love of mythology had been “quickened to full life by war.” Yet he chose not to write a war memoir, and in this he departed from contemporaries like Robert Graves and Vera Brittain.

In the postwar years, the Somme exemplified the waste and futility of battle, symbolizing disillusionment not only with war, but with the very idea of heroism. As a professor of Anglo-Saxon back at Oxford, Tolkien preferred the moral landscape of Arthur and Beowulf. His aim was to produce a modern version of the medieval quest: an account of both the terrors and virtues of war, clothed in the language of myth.

In “The Lord of the Rings,” we meet Frodo Baggins and Samwise Gamgee, Hobbits of the Shire, on a fateful mission to destroy the last Ring of Power and save Middle-earth from enslavement and destruction. The heroism of Tolkien’s characters depends on their capacity to resist evil and their tenacity in the face of defeat. It was this quality that Tolkien witnessed among his comrades on the Western Front.

“I have always been impressed that we are here, surviving, because of the indomitable courage of quite small people against impossible odds,” he explained. The Hobbits were “a reflection of the English soldier,” made small of stature to emphasize “the amazing and unexpected heroism of ordinary men ‘at a pinch.’ ”

When the Somme offensive was finally called off in November 1916, a total of about 1.5 million soldiers were dead or wounded. Winston Churchill, who served on the front lines as a lieutenant colonel, criticized the campaign as “a welter of slaughter.” Two of Tolkien’s closest friends, Robert Gilson and Ralph Payton, perished in the battle, and another, Geoffrey Smith, was killed shortly afterward.

Beside the courage of ordinary men, the carnage of war seems also to have opened Tolkien’s eyes to a primal fact about the human condition: the will to power. This is the force animating Sauron, the sorcerer-warlord and great enemy of Middle-earth. “But the only measure that he knows is desire,” explains the wizard Gandalf, “desire for power.” Not even Frodo, the Ring-bearer and chief protagonist, escapes the temptation.