The story of Book 5 started out when Gandalf rode with Pippin towards Minas Tirith. Gandalf was taking Pippin there because Pippin had looked into the Palantir; they were also going to help with the war effort against the orcs.
After Pippin and Gandalf had arrived, the orcs, who were creatures of Mordor, surrounded Minas Tirith; they dug out trenches and shot the Men of Gondor with arrows, and then they launched the Men of Gondors" heads back into the city with their cannons. The orcs also hurled balls of fire at the city, and later the city caught on fire. The people of the city thought that there was no hope.
Even though they thought there was no hope, faithful men died trying to defend the city of Minas Tirith. The orcs broke down the gate to the city, but Gandalf forbade them to pass through into the city. However, Gandalf was interrupted by Pippin, who told him that the king was about to kill himself, and his son. Gandalf then hurried to try and save them, but he saved only the king's son; the king killed himself before anyone could stop him.
Upon the king's death, Aragorn and two companions went through the Paths of the Dead to reach the city, but before they did, the Riders of Rohan got to the city and started defeating the orcs. The Lord of the Nazgul was stabbed by Merry, who suffered from a temporary loss of use in his arm that held the sword. The Riders of Rohan and the rest of the Men of Gondor finally defeated the orcs around Minas Tirith.
After the defeat of the orcs, Gandalf suggested that the men of Gondor and Rohan make an army and go attack the gate of Mordor, so they could take the focus of the eye of Mordor away from the Ring-bearer and onto them. They built up a small army, but they built one that was made up of powerful soldiers. The ending of the story is when Gandalf's army attacked the gate of Mordor.
The story of Book 6 began with Sam trying to save his master Frodo, who had been taken in as a prisoner at a tower of the orcs.