What happens if the US election is contested?

Even if the election is messy and contested in court, the country will have a president on Inauguration Day. The Constitution and federal law ensure it.