Elections to the presidency are not first-past-the-post, which is plurality voting, i.e. you can win with the single greatest number of votes cast, even if that’s less than a majority of the votes cast.
To be elected president, a candidate has to win a majority of the electoral votes. If no candidate receives a majority of the electoral votes, it goes to the House of Representatives, as set out in the Twelfth Amendment:
The person having the greatest number of votes for President, shall be the President, if such number be a majority of the whole number of Electors appointed; and if no person have such majority, then from the persons having the highest numbers not exceeding three on the list of those voted for as President, the House of Representatives shall choose immediately, by ballot, the President. But in choosing the President, the votes shall be taken by states, the representation from each state having one vote; a quorum for this purpose shall consist of a member or members from two-thirds of the states, and a majority of all the states shall be necessary to a choice.
Of course, that hasn’t happened since 1824, due to the strength of the party apparatus.
(And if you mean by the popular vote, not the electoral vote, that’s not plurality voting either, since the system allows for the candidate with the second-greatest number of popular votes to be beat the candidate with the greatest number of popular votes. That’s not first-past-the-post.)