He has 300 foreign policy advisers and the chairman of the Senate Foreign Relations committee is his vice presidential nominee. And yet Barack Obama's foreign policy is still all twists and turns, forever adapting to every change in the political circumstances.

Terrorist surveillance? Obama was against this year's revision to the Foreign Intelligence Surveillance Act, until he voted for it.

Negotiations with rogue dictators? In 2007 Obama pledged to meet with Iranian president Mahmoud Ahmadinejad and his friends "without precondition." But that was so last year. These days, Obama hedges. He says "preparations" will take place before any summits, and that those summits will occur only if he thinks they will further American national security interests.

The surge? Obama was a vocal opponent. He predicted that sending reinforcements to Iraq and changing strategy would not just fail but indeed make things worse. Didn't happen, of course. And now the other day Obama said the surge has succeeded beyond "our wildest expectations." His expectations, certainly.

On issue after issue, Obama's small army of wonks has not been able to keep him from stumbling. His instinct, of course, is to stake out positions on the left. But reality intrudes. It forces Obama to adjust. A talented writer, he is keenly aware of subtle distinctions in word choice and emphasis, and the shifts in position are sometimes difficult to detect. But they are there nonetheless. And so often Obama follows in the footsteps of his true foreign policy mentor: John McCain.

As the story goes, shortly after coming to Washington, Obama sought out McCain to tell him that he was a role model. The two were friends until a dispute over an ethics bill soured the relationship. But Obama still took, and continues to take, foreign policy cues from McCain. On many issues there is little difference between the two candidates. They both oppose torture and want to shut down the terrorist prison at Guantánamo Bay. They both support expanding the Army and Marine Corps. They both support a cap-and-trade scheme to limit carbon emissions. Both promise to reach the quixotic goal of "energy independence." Both want to send more troops to Afghanistan, recognize the sovereignty of Kosovo, and support NATO expansion. Both repeatedly say that America is an exceptional country. Neither man forswears the use of force to prevent Iran from obtaining nuclear weapons. And both say unilateral military action is always an option.

Where there is divergence, it doesn't last long. In December 2006 the Senate debated a civilian nuclear cooperation agreement between the United States and India. That agreement--the product of long, intense negotiations between the Bush administration and the Indian government--will cement a new strategic alliance between our two countries. Yet Obama voted for a series of so-called "killer" amendments that would have made the agreement dead on arrival. His side lost. A bipartisan group of senators, including Biden and McCain, were able to defeat the amendments Obama supported. And once those amendments had been defeated, something curious happened. Obama completely changed his tune. He became a vocal supporter of the deal (which must be approved by Congress once more before taking effect).

When Russia invaded Georgia last month, Obama released a statement condemning the "outbreak of violence" and urging both sides to show "restraint." A sorry response. An "outbreak" suggests there was no agency behind the war. That it simply sprung into being. Not so. Russia invaded. Russia was responsible. And it was Russia, not the defeated Georgians, which needed--and still needs--to show "restraint."

McCain's response could not have been more different from Obama's. He did not equivocate. He called Russia what it is--the aggressor in an unjustified war. And he was unafraid to express solidarity with a fellow democracy, saying, "We are all Georgians." For this he was called a reckless warmonger by many on both the left and the right. Obama's chief foreign policy adviser--the secretary general of the 300--actually suggested McCain had made the situation worse by condemning it.

But what did Obama do? As time passed, he began to sound more like .  .  . McCain. Every so often he would emerge from his vacation digs in Hawaii and ratchet up the rhetoric. In a later statement, Obama said there was no justification for Russia's actions. He called on Russia to end the violence immediately. He supported economic aid to Georgia to help reconstruct that battered country. On Georgia, the differences between the two candidates grew smaller and smaller. And soon only one difference remained. McCain had been there first.

Then there is Iraq. During the Democratic primaries, I wrote that, if elected, Obama would stick to his artificial timeline for withdrawal from Iraq no matter what ("They Really Do Plan to Surrender" in the April 21, 2008, WEEKLY STANDARD). I'm not so sure anymore. These days Obama's goal--withdrawing combat troops from Iraq within 16 months of taking office--seems more a hope than a plan. In July, Obama told Newsweek his withdrawal would be "entirely conditions based," meaning the redeployments could slow down, or end, if violence in Iraq took a turn for the worse. A conditions-based withdrawal is exactly what General Petraeus and McCain support.

Meanwhile, Obama says the United States needs to be as "careful" leaving Iraq as we were "careless" going in. Another word for "careful" is "slow." And Obama calls for a "rapid reaction force" that would be used to control violence and "prevent the conflict in Iraq from becoming a wider war." Except Obama has not said how large his "rapid reaction force" will be or where it will be deployed. Thousands of troops? Tens of thousands? In Iraq? Kuwait? Timbuktu?

Whatever the case, it looks like Obama now intends for there to be a substantial American troop presence in Iraq for some time to come. Faced with the prospect of governing, he has shunted aside the rhetoric and policies that so titillated the left during the Democratic primary. He still may occasionally feint in that direction. But his overall course is steadily toward the center. Toward an internationalist foreign policy well within the tradition of recent presidents. Toward a substantial American engagement with the world and the maintenance of American primacy. Toward McCain.

Matthew Continetti is the associate editor of THE WEEKLY STANDARD .