King Ondoher led the main army north to counter the Easterling invasion at Dagorlad and was defeated.
Eärnil was commander of Gondor's southern army and guarded Pelargir. Eärnil led his army to the Crossings of the Poros were he won a astounding victory over the Haradrim.
This enabled him to turn his attention to the invading Wainriders. The Wainriders, certain of victory, were celebrating their success before they would enter Minas Anor. They were unaware of Eärnil's victory in the south and were taken by surprise when Eärnil suddenly attacked them. As a result Eärnil won the Battle of the Camp.
Both he and prince Arvedui of Arthedain claimed the throne. Arvedui had the strongest claim but Eärnil was elected king because of his glorious deeds and heritage (he came from Gondor while Arvedui came from ancient Arnor). He reigned as Eärnil II.
Aside from being a gifted general Eärnil also was a wise ruler. He promised Arvedui (heir to his own kingdom) the he would come to Arthedain's aid.
In 1974 Third Age Eärnil heard that Arthedain was in jeopardy and he sent an army under the lead of his son Eärnur to the north to aid Arvedui (now king).
Eärnil wasn't able to withstand the takeover of Minas Ithil by the Ringwraiths, Minas Anor was promptly renamed Minas Tirith (Tower of Guard) and Minas Ithil was called Minas Morgul (Tower of Sorcery)
Eärnil died in 2043 Third Age and was succeeded by his son Eärnur, who was as good a general as his father but lacked his wisdom.