All votes count! However, the final outcome of the election is determined by the Electoral College. When you vote for a presidential candidate you are really voting to instruct the electors from your state to cast their votes for the same candidate that took the majority vote in your state. This system was established in Article II of the Constitution and amended by the 12th Amendment in 1804.
Four times in history a candidate lost the popular vote but won the election by way of the electoral count. They were John Quincy Adams, Rutherford B. Hayes, Benjamin Harrison, and George W. Bush.
Each state gets electors equal to the number of U.S. House of Representatives plus one for each of its two U.S. Senators. The District of Columbia gets three electors. While state laws determine how electors are chosen, they are generally selected by the political party committees within the states.
Each elector gets one vote. If a state has eight electors then eight votes would be cast. There are currently 538 electors and the votes of a majority of them, 270 votes, are required to elect the president. The map below shows how many electors each state has.
If no candidate wins 270 electoral votes, the 12th Amendment kicks in, and the election is decided by the House of Representatives. The combined representatives of each state get one vote and a simple majority of states is required to win. This has only happened twice. Presidents Thomas Jefferson in 1801 and John Quincy Adams in 1825.
The night of the election a winner will be declared by all the news outlets. One candidate will claim victory and one will normally concede defeat. It will not become "official" and a new president and vice president named "elect" until the first Monday after the second Wednesday in December, when the electors of the Electoral College meet in their state capitals and cast their votes according to which candidate won the majority of their states popular vote.