McCain countered in the safest of Republican states.
Obama's triumph in Pennsylvania left the Republican with scant room for error.
"May God bless whoever wins tonight," President Bush told dinner guests at the White House, according to spokeswoman Dana Perino.
McCain had Arkansas, Kentucky, Tennessee, Oklahoma, Wyoming, Alabama and South Carolina.
The nationwide popular vote was remarkably close. Totals from 13 percent of the nation's precincts showed Obama with 49.9 percent and McCain with 49.2.
Pushing back against predictions of defeat, Republican John McCain scheduled campaign stops in two western battlegrounds on Election Day after a seven-state sprint that brought him home to Arizona after midnight Tuesday.
It is John McCain's second run for president. He has been deeply involved in other national campaigns. He says he comes in on Election Day with experience that he says tells him he has the energy, enthusiasm and support to pull off a stunner.
The public knows who he voted for. John McCain cast his ballot in Phoenix at a church not far from where he will watch returns on Tuesday night and then meet with supporters on a beautiful lawn at the Biltmore resort.
McCain is still predicting victory but he sounded a bit sad that the nearly two year long campaign is at its end.
"In a way, I'm kind of sorry that it's over because it has been exciting. I mean, it's been one of the most incredible experiences that anybody can have," said Sen. McCain.
McCain told supporters at a rally in Prescott, Arizona just after midnight that every vote counts in this campaign and he still intends to prove the pundits wrong. He is hitting rallies in Grand Junction, Colorado, and Albuquerque, New Mexico on Tuesday.
Vice-presidential candidate Sarah Palin and her husband Todd returned to Wasilla, Alaska, overnight. They cast their ballots at city hall in the town where Sarah Palin served as mayor for six years, ending in 2002.
"Such an honor, of course, to get to be able to be back home with my friends and family to exercise my right to vote. Being just one of millions across America today," said Gov. Palin.
In Arizona just after midnight, John McCain was asked in an interview whether, looking back on his campaign, he would he have done anything differently, and he said absolutely not. McCain said he has no regrets, just plenty of good memories.
The Associated Press contributed to this report.