Legolas and Aragorn and Gimli ride to Helm's Deep once more, with a following of Dunadane (northern rangers like Aragorn) and Elrond's twin sons, Elrohir and Elladan. They say that they are going to pass through the Pass of the Dead, in which no mortal has ever done. Of course Legolas isn't afraid, he's immortal.
After Aragorn gathers for himself a grand army of dead people, they march toward the sea. It is here that Legolas first hears the calling of the sea and ever since then he wishes for nothing else than to travel to the west. However, his strong ties in Middle-earth tear at him and he refuses to go west until all the fellowship has passed on.
They fight in a battle near the seas and then, on huge boats that were originally Sauron's men's, they arrive just in time to save Minis Tirith. However, I believe he was wounded in the battle, since the book states that only, "Aragorn, Eomer, and Imrahil were unscathed."
After a reunion with Merry and Pippin once more, they set out for Mordor to confront Sauron on his own doorstep. The battle is fierce but in the end good triumphs and they return to Minis Tirith in celebration and praise for the ringbearers, Frodo and Sam.
After Aragorn and Arwen's wedding, Legolas and Gimli part ways with the fellowship and head out to fullfill the promises they made to one another.
In the end however, Legolas returns to Minis Tirith many times and even brings some of his people from Mirkwood to live in the forests of Ithilian not far from Aragorn's palace.
(At least, I believe that is what happened. Though, I am sorry to say that I'm not sure so do not take that statement as the gospel truth.)
To end the story of The Lord of The Rings, it is said that after Aragorn died, Legolas built a boat and, taking Gimli with him, sailed into the undying lands, never to be heard from in Middle-earth again.
Thus passed the last of the fellowship of the ring.