in due time , galvahir and the other heroes defeated agon by the power of the holy sword of pelas and drove him over the mountains to the wastelands of amlaman , where he was condemned to dwell for all eternity .