It's during the Thirty Years War and war and plague are destroying the people of Europe. Vogel (Sharif), a professor on the run from the carnage witnesses the destruction of a village and runs for his life. He stumbles upon a pristine valley untouched by the war.
There are no people around the village though everything looks to be prosperous. Vogel falls asleep only to be awakened by the arrival of the army from which he was running. He negotiates with The Captain (Caine) for his life explaining that he can talk to both peasant and soldier. The Captain gives him 48 hours to bring the villagers back. the Captain agrees to winter in the valley instead of returning to his army which is starving and plague ridden.
The villagers are opposed to having the soldiers stay but soon realize they have no option. So an uneasy alliance is formed with many bumps along the way. As the Thirty Years War was heavily centered on religion, the Catholic town is often at odds with the Protestant soldiers. When the Captain wants to destroy the shrine which protects the village he bargains with the head of the village to keep the shrine in exchange for the village providing six women to serve as comfort to the soldiers. Plenty of jealousy and possessiveness ensues as the six women are chosen for this task. The village priest promises that the women will not go to hell for sleeping with the soldiers because they have saved the village.
The Captain plays a game of dice for the wife of Gruber (the village leader) and loses, but the wife lies and says he actually won (perhaps because she really prefers the Captain or because she realizes the village will be destroyed if the Captain loses.)
When the villagers hear that the shrine is being moved they take up arms to fight the soldiers, but Vogel intercedes and claims he dreamed that the shrine had to be moved to save the village. This pacifies the villagers.
Meanwhile conflict over the six comfort women leads to an attempted rape (of Inge) which Vogel prevents and then an attempt on the life of the Captain which is unsuccessful. The Captain organizes a party to go after the mutineers but they escape.
The Captain discovers the woman he won from Gruber(Erica) practices witchcraft but vows to protect her from the priest. As the mutineers return with hundreds of soldiers from the army, the village prepares to defend itself. A bloody battle ensues with lots of grotesque mayhem on both sides. The Captain lures the surviving mutineers into a trap where yet another bloody battle develops. The villagers and the Captain defeat the mutineers and the leader (Hanson) is publicly castrated for his role in the original attempted rape.
As winter sets in all is peaceful in the village though the Captain is reluctant to let down his guard. The winter passes without incident but Gruber's growing jealousy of the Captain who has been living with his wife since he "lost" her in the dice game begins to show. During a huge spring party news from the outside comes that the war has had terrible consequences and that cannibalism has broken out across Germany. The messenger's news indicates that soon the valley will be the site of a confrontation between the nearby armies.
The Captain decides to join the side of the Protestants and during a confrontation with the village priest he declares his contempt for both sides in the religious war. "There is no hell because there is no God. It's just a legend."
As the battle looms near, Vogel is asked by Inge to take her with him. Vogel turns her down because he claims he can't protect her and that after all he has seen he's not really capable of love. Likewise, Gruber's wife begs the Captain to take her away as well. The Captain refuses and orders Vogel to stay and protect the village making sure to kill the priest first. Vogel tries to convince Gruber to build an army of the villagers and Gruber indicates he is prepared to defeat the Captain if he should ever return.
The priest discovers that Erica is a witch and condemns her to death. Gruber and Vogel stand by as she is tortured by the priest. In order to prevent her from being burned alive, Vogel stabs her to death unbeknown to the villagers who then burn her body. Rage overcomes one of the soldiers left with Vogel and he throws the priest into the fire as well.
Meanwhile, the Captain and his men jin the fight at the bridge over the Rhine that both sides badly want to control. Murderous hand-to-hand combat ensues and it appears the Captain has been killed.
Back in the village Vogel is confronted by Inge's father because he believes Vogel has bad intentions. Vogel decides to run and warn the Captain of the ambush that awaits him should he return and Inge joins Vogel in the quest. The Captain was not killed but is badly injured and rides right into the ambush before he can be warned. His injuries are apparent to Gruber and the villagers so they don't attack. The Captain tells Vogel that all his men are dead except two. The Captain, in his delirium believes Inge is Erica and she pretends she is so that the Captain can make his final testimony of his love. His dying words are to Vogel about the splendor of the valley.
As Gruber prepares to kill Vogel, Inge declares her love for Vogel and Gruber and the assassins back down. Vogel refuses to take Inge and heads off into the fog.