At the moment, the state of the presidential race is in flux, although that could solidify very fast. One possible scenario is that due to third-party candidates, Hillary and Trump will both fail to secure 270 electoral votes, in which case the election will be thrown into the House. I asked a friend who knows more about the mechanics than me what the procedure would be in that event. He said:
Article II, Section 1, Clause 3 of the Constitution lays out the rules in such a scenario. That language is a bit confusing, but the gist is:
The House gets to elect the President and must choose from the from the 3 nominees who got the most Electoral votes (Trump, Hillary, or McMullin). Each state gets one vote (presumably the party with the most Reps gets to decide) so 26 states are needed to win.
The Senate would elect the Vice President from the 2 Vice Presidential candidates with the most Electoral votes (Pence or Kaine, but not Finn). Each Senator gets one vote.
If the House can't decide on a President by Inauguration Day, the Vice-President Elect (Kaine or Pence) serves as acting President until the deadlock is resolved.