He was asked during a TV interview to react to Mr McCain's recent description of him as the 'Hamas' favourite' to win the presidential election.
A senior official of the Palestinian terrorist group recently said Hamas hoped Mr Obama would win the presidency.
Mr McCain has been drawing attention to this, saying: 'If Obama is favoured by Hamas, I think people can make judgments accordingly.'
Mr Obama responded sharply on Thursday, calling it an offensive smear which showed that his rival had 'lost his bearings'.
'This is offensive, and I think it's disappointing, because John McCain always says, 'Well, I'm not going to run that kind of politics',' Mr Obama said, pointing out that his policy towards Hamas was the same as Mr McCain's.
He added: 'For him to toss out comments like that, I think, is an example of him losing his bearings as he pursues this nomination.'
For that, the McCain campaign has accused Mr Obama of trying to make an issue of Mr McCain's age.
It was 'a not particularly clever way of raising John McCain's age as an issue', said Mr Mark Salter, a McCain adviser.
Age is a touchy issue for Mr McCain, who turns 72 in August and would, if he won, be the oldest first-term president. Mr Obama often slyly compliments Mr McCain's 'half a century of honourable service' - drawing attention to his age.
Reports say both campaigns are at work compiling attack advertisements. Mr Obama will try to link his rival to the unpopular policies of President George W. Bush, while Mr McCain will question Mr Obama's inexperience and readiness to be commander-in-chief.
BHAGYASHREE GAREKAR