The Song of Roland (La Chanson de Roland) is an 11th century Old French epic poem about the Battle of Roncevaux Pass (or Roncesvalles) fought by Roland of the Brittany Marches and his fellow paladins. The Song is based on historical events surrounding the battle of August 15, 778 in which the rear-guard of Charlemagne's retreating Franks was attacked by Basques; in the ensuing massacre, Roland and other important paladins were killed. The Song transforms the Basques into Muslims and takes other liberties with the history. For instance, the Song has Charlemagne and a French army returning to Spain and in retaliation driving the Muslims out of Zaragoza.
In fact, Charlemagne failed to conquer Zaragoza and left Spain after Roland was killed, not returning until 801 when he captured Barcelona. The epic takes much poetic licence with history, as the poem's function is in part to strengthen Christians' resolve against Islam during the Crusades of the 11th century. However, while the account of the song does not match history, it is considered a classic example of the virtues of chivalry.
Charlemagne and his army are fighting in Spain. Marsilion, the Saracen King of Zaragoza sends envoys to negotiate with Charlemagne: if Charlemagne returns home to Aix-la-Chapelle, Marsilion will follow and convert to Christianity. Charlemagne's lords disagree over how they should respond; Roland distrusts Marsilion, but Ganelon, Naimon and most of the others are in favour of trusting him. Charlemagne agrees, but Roland recommends that Ganelon be the one to take the agreement to Marsilion. This angers Ganelon, and while in Zaragoza, he plots revenge.
In Zaragoza, Ganelon tells Marsilion that he will only be allowed to keep half of Spain: the rest must go to Roland. Marsilion offers Ganelon friendship, and they plot together to betray Roland by attacking the Frankish army as it returns to France. Marsilion raises a vast army to do so, while Ganelon returns to the Franks and successfully goads the honorable Roland into leading the vulnerable rear guard of the army.
The Saracens attack the rear of the Frankish army. Roland's friend Oliver advises him to blow his horn Olifant to summon the rest of the army. But Roland's code of honour obliges him to fight despite being outnumbered. The Franks are massacred, and at the end, Roland eventually sounds his horn, but it is too late. All his men are killed, but Roland, in his final act routs the last few Moorish forces before finally succumbing to his injuries.
By the time Charlemagne actually gets to the battle, his men are all dead, although Roland and the paladins have forced the Moors to flee. Marsilion has lost his right hand to Roland's sword (Durandal). Charlemagne mourns over Roland's body, and vows revenge, gathering an army of Franks, Bavarians, Germans, Normans, Bretons, Flemings, and Burgundians to destroy the Muslim army, led by Balignant, Emir of Babylon. The Christians destroy the Muslims, Balignant is killed, and the Muslims flee as the French triumph.
The synagogues and mosques of Zaragoza are smashed, and 100,000 Muslims and Jews are baptized. The Franks then return to Aix-la-Chapelle. Roland's wife Auge dies of grief. Ganelon is tried for treason, and fights a legal battle, claiming he took vengeance not treason. To settle the dispute, Ganelon's friend Pinabel fights judicial combat with Roland's friend Thierry, who wins. Ganelon is executed by having his limbs pulled off by four horses. Queen Bramimond is baptized, and Charlemagne is finally satisfied.