Essentially, as the administration has taken a more pragmatic approach to foreign policy, the decision of Mr. McCain to adhere to his more hawkish positions illustrates the continuing influence of neoconservatives on his thinking even as they are losing clout within the administration.

Whether the perception of Mr. McCain as being at odds with the administration is politically advantageous for him is a matter of debate among his supporters, but many of his more conservative advisers do not think it is a bad thing.

“There’s no doubt, particularly as Bush has adopted policies in the direction of Obama, that that gives Obama bragging rights,” said John R. Bolton, the Bush administration’s former ambassador to the United Nations, who has sharply criticized the administration’s talks with Iran and North Korea. “But if you believe as I do that this administration is in the midst of an intellectual collapse, it doesn’t hurt McCain. Occasionally in politics it helps to be right.”

But other Republicans  the so-called foreign policy pragmatists, many of whom have come to view the Iraq war as a mistake  say the administration’s policy shifts highlight the more confrontational nature of Mr. McCain’s foreign policy, particularly in his approach toward Russia and his embrace on Friday of the Dalai Lama, whom the Chinese regard as the fomenter of a rebellion in Tibet. They say the meeting will only antagonize China before the Summer Olympics, and at a moment when the United States is seeking its cooperation on economic issues and negotiations with North Korea.

The divisions within the Republican foreign policy establishment continue at a time when Mr. Obama is trying to establish his own international credentials. Republicans worry that he is seizing the chance, helped with the boost from Mr. Bush, to command the American foreign policy stage.