The two men clashed over spending, taxes, energy and - at length - the war in Iraq during their 90-minute debate.
McCain accused his younger rival of an "incredible thing of voting to cut off funds for troops in Iraq and Afghanistan," a reference to legislation that cleared the Senate more than a year ago.
Obama disputed that, saying he had opposed funding in a bill that presented a "blank check" to the Pentagon while McCain had opposed money in legislation that included a timetable for troop withdrawal.
Obama opposed the invasion of Iraq in 2002, before he was a member of Congress, while voted to authorize the war as a member of the Senate.
"You were wrong" on Iraq, Obama repeated three times in succession. "John, you like to pretend the war began in 2007."
McCain replied that Obama has refused to acknowledge the success of the troop buildup in Iraq that McCain recommended and Bush announced more than a year ago.
The two presidential candidates stood behind identical wooden lecterns on stage at the performing arts center at the University of Mississippi for the first of three scheduled debates with less than six weeks remaining until Election Day. The two vice presidential candidates will meet next week for their only debate.
The 47-year-old Obama is seeking to become the nation's first black president. McCain, 72, is hoping to become the oldest first-term chief executive in history - and he made a few jokes at his own expense.
"I've been around a while," he said at one point. "Were you afraid I couldn't hear you?" he said at another after Obama repeated a comment.
It was a debate that almost didn't happen. McCain decided at the last minute to attend, two days after announcing he would try to have the event rescheduled if Congress had not reached an agreement on an economic bailout to deal with the crisis now gripping Wall Street.
The two men were pointed but polite as they covered most issues, although at least once, McCain sought to depict his rival as naive on foreign policy. That was particularly true when it came to Obama's statement that it might become necessary to send U.S. troops across the Pakistani border to pursue terrorists.
"You don't say that out loud," retorted McCain. "If you have to do things, you do things."
McCain also seemed eager to demonstrate his knowledge of foreign policy, recalling the names of three former leaders of the Soviet Union in one sentence.
Moderator Jim Lehrer's opening question concerned the economic crisis gripping Wall Street. While neither man committed to supporting bailout legislation taking shape in Congress, they readily agreed lawmakers must take action to prevent millions of Americans from losing their jobs and their homes.
Both also said they were pleased that lawmakers in both parties were negotiating on a compromise.
McCain made a point of declaring his independence from Bush.
"I have opposed the president on spending, on climate change, on torture of prisoners, on Guantanamo Bay, on a long - on the way that the Iraq War was conducted. I have a long record and the American people know me very well ... a maverick of the Senate."
He jabbed at Obama, who he said has requested millions of dollars in pork barrel spending, including some after he began running for president.
As he does frequently while campaigning, the Republican vowed to veto any lawmaker's pork barrel project that reaches his desk in the White House. "You will know their names and I will make them famous," he said.
The stakes were high as the two rivals walked on stage. The polls gave Obama a modest lead and indicated he was viewed more favorably than his rival when it came to dealing with the economy. But the same surveys show McCain favored by far on foreign policy.
Both candidates had rehearsed extensively, Obama prepping with advisers at a resort in Clearwater, Fla., and McCain putting in debate work at his home outside Washington.
The two presidential hopefuls are scheduled to debate twice more, at Belmont University in Nashville on Oct. 7 and at Hofstra University in Hempsted, N.Y., on Oct. 15. Vice presidential contenders Sarah Palin and Joe Biden are to square off in a single debate Oct. 2 at Washington University in St. Louis.