In short, once the candidates are decided upon (typically representatives of the two main parties du jour chosen through primary elections and an assortment of chanceless "third parties"), a nationwide vote is held on the first Tuesday after the first Monday in November.
The ballot for this election may have the names of the candidates on it, but what people are actually voting for is electors to represent them when it comes time for the Electoral College to vote for the President and Vice President. Each state (and the District of Columbia) receives a number of electors equal to its entire Congressional delegation. For example, my home state of Massachusetts has 10 Representatives and 2 Senators, giving the Democratic candidate 12 electoral votes each election (grumble, grumble, winner-take-all...). The District receives a number of electors equal to that of the lowest state, for a grand total of 538 (at present). Most states operate under a winner-take-all system, whereby the winner of the popular vote in each state gets the entirety of the state's electoral votes. Maine and Nebraska use a different system; I'm a little fuzzy on it, but I'm pretty sure they give their state winner 2 electoral votes and divvy up the remainder proportionally.
In many states, the electors are required to vote as directed by the popular vote of their state (subject to state law); "faithless electors" can be punished for failing to vote as directed. The electors meet in their state capitals on the first Monday after the second Wednesday in December. At this point, they then cast two votes: one for the office of the President and one for the office of the Vice President. Despite the fact that we tend to see two-person Pres/VP tickets, the vote of the electors is not technically linked. It would be possible, though highly unlikely, for electors to reject the actual winner of either position and install someone else.
Once the votes are cast, they are sent to Congress. In a joint session before the House and the Senate, the electors' votes for the President and the Vice President are tallied. If a candidate receives half+1 of the votes, that person is elected to the office. In the event that there are insufficient electoral votes to elevate a candidate to office, Congress gets to decide. If no candidate won the Presidency, then the House of Representatives votes for a candidate (who again need not be the original contender). If the Vice Presidency remains contested, the Senate votes on candidates.
However the decision is made, the new President and Vice-President are installed on January 20. Their terms begin at noon and last for four years.