In the Second Age, Isildur brought with him a large stone (the height of a man) as a symbol of his lineage and Gondor. He set it on the hill of Erech. He made the local hill tribes swear an oath of loyalty on the stone. The hill tribes later broke their oath and were doomed to haunt the place as the Dead Men.
The area was completely abandoned by the end of the Third Age, when the heir of Isildur, Aragorn, came to Erech to hold the Dead to their oath again. This time they held true to their oath and formed the Host of the Dead to help Aragorn defeat the Corsairs of Umbar at Pelargir.
After the battle at Pelargir, Aragorn released them from their oath and they were allowed to rest.