Gondor was founded by
Elendil when he came to
Middle-earth after he escaped the
Downfall of Numenor in the year 3320 of the Second Age. It was first ruled by
Elendil's sons Anárion and
Isildur, but the first perished in the War of the Last Alliance as did
Elendil himself and the latter died shortly after in the
Disaster of the Gladden Fields. Anárion's son Meneldil ruled Gondor after this, so all the Kings of Gondor up to Eärnur were descendants of Anárion, youngest son of
Elendil. The line of Kings was broken when Eärnur was lost in Minas Morgul after being challenged by the Witch-king. After this tragedy, Gondor was ruled by the King's Stewards and the first of these Ruling Stewards was Mardil Voronwë (starting his reign in the year 2050 of the Third Age). The Stewards swore an oath in which they said they would rule until the King would come back, originally talking about Eärnur whose fate was not yet known. In the year 3019 of the Third Age, Aragorn II Elessar was crowned King of Gondor, being a descendant of Anárion's elder brother
Isildur, who was
Elendil's heir.