The first of those wars ended after the Siege of Barad-dûr, when its Lord Sauron was thrown down, and his spirit cast out of his body. After that time, Barad-dûr was demolished, and the ways into Mordor were guarded by the Gondorians to prevents its old master's return. So Sauron was an exile from his own land throughout most of the Third Age, but late in that Age, with the guard of Gondor long since abandoned, he took his opportunity to escape back into Mordor, and rebuild the Dark Tower. From that time, and throughout the War of the Ring, he became the Lord of Barad-dûr once more.