Most of the time, electors cast their votes for the candidate who has received the most votes in that particular state. However, there have been times when electors have voted contrary to the people's decision, which is entirely legal.
When the Electoral College Counted
In most presidential elections, a candidate who wins the popular vote will also receive the majority of the electoral votes, but this is not always the case. There have been four presidents who have won an election with fewer popular votes than their opponent but more electoral votes.
Here are the four elections when the candidate who led the popular vote did not win the office:
1824: John Quincy Adams, the son of former President John Adams, received more than 38,000 fewer votes than Andrew Jackson, but neither candidate won a majority of the Electoral College. Adams was awarded the presidency when the election was thrown to the House of Representatives.
1876: Nearly unanimous support from small states gave Rutherford B. Hayes a one-vote margin in the Electoral College, despite the fact that he lost the popular vote to Samuel J. Tilden by 264,000 votes. Hayes carried five out of the six smallest states (excluding Delaware). These five states plus Colorado gave Hayes 22 electoral votes with only 109,000 popular votes. At the time, Colorado had been just been admitted to the Union and decided to appoint electors instead of holding elections. So, Hayes won Colorado's three electoral votes with zero popular votes. It was the only time in U.S. history that small state support has decided an election.
1888: Benjamin Harrison lost the popular vote by 95,713 votes to Grover Cleveland, but won the electoral vote by 65. In this instance, some say the Electoral College worked the way it is designed to work by preventing a candidate from winning an election based on support from one region of the country. The South overwhelmingly supported Cleveland, and he won by more than 425,000 votes in six southern states. However, in the rest of the country he lost by more than 300,000 votes.
In 2000, Al Gore received 50,992,335 votes nationwide and George W. Bush received 50,455,156 votes. After Bush was awarded the state of Florida, he had a total of 271 electroral votes, which beat Gore's 266 electoral votes.
Today, a candidate must receive 270 of the 538 votes to win the election. In cases where no candidate wins a majority of electoral votes, the decision is thrown to the House of Representatives by virtue of the 12th Amendment. The House then selects the president by majority vote with each state delegation receiving one vote to cast for the three candidates who received the most electoral votes.
Here are the two elections that were decided by the House of Representatives:
1801: Thomas Jefferson and Aaron Burr, both Democrat-Republicans, received the same number of electoral votes, despite the fact that Burr was running as a vice presidential candidate, not for the presidency. Following 36 successive votes in the House, Jefferson was finally elected president.
1825: As mentioned above, Andrew Jackson received a majority of the popular vote over John Quincy Adams, but neither man received a 131-vote majority of electoral votes needed at the time to claim the presidency. Adams won the House vote on the first ballot.
_________
How The Electoral College Works
http://www.fec.gov/pages/ecworks.htm