Let’s all take a stroll down memory lane, shall we?

Readers will recall that Barack Obama’s presidential candidacy was built on his opposition to the Iraq war, and when he was in the U.S. Senate, he demanded that America end its involvement there, even though doing so would have led to an epic American defeat. Iraq was a “dangerous distraction,” Obama said, and he clearly believed it was destined to end badly.

As I documented in this essay for COMMENTARY, in late 2006 Obama argued for a “phased withdrawal” from Iraq. “We cannot, through putting in more troops or maintaining the presence that we have, expect that somehow the situation is going to improve,” he predicted.

On January 10, 2007, when President Bush announced his administration’s change in strategy in Iraq, popularly dubbed the “surge,” Obama declared he saw nothing in the plan that would “make a significant dent in the sectarian violence that’s taking place there.” A week later, he repeated the point emphatically: the surge strategy would “not prove to be one that changes the dynamics significantly.” Later in the same month, he summed up in these words his impression of the hearings on the new strategy held by the Senate Foreign Relations Committee: “What was striking to me, in listening to all the testimony that was provided, was the almost near-unanimity that the President’s strategy will not work.”

On February 10, 2007, in announcing his presidential candidacy, Obama declared he had a plan “that will bring our combat troops home by March of 2008.”

In May 2007, Obama voted in the Senate against funding for combat operations. And in September, a mere three months after the final elements of the 30,000-strong surge forces had landed in Iraq, he declared that the moment had arrived to remove all of our combat troops “immediately.” “Not in six months or one year—now.”

Iraq, it was commonly said, was riven by sectarian differences that could never be overcome. Democracy could never take root in its hard, unforgiving soil. And even if it could, it would be uprooted by anti-democratic forces within the country.

By the time Obama became president, the Iraq war had turned around so dramatically that it was obvious even to him. Obama wisely decided against a precipitous withdrawal of American forces; he instead decided to abide by the Status of Forces Agreement (SOFA) his predecessor had negotiated. Nevertheless, Obama continued to denigrate what had been achieved in Iraq, repeatedly pointing to it as an American foreign policy failure, and in the process, misrepresenting the facts. For example, in his much ballyhooed Cairo speech on June 4, 2009, Obama said, “I know there has been controversy about the promotion of democracy in recent years, and much of this controversy is connected to the war in Iraq. So let me be clear: no system of government can or should be imposed upon one nation by any other.”

That statement was false. In the aftermath of deposing Saddam’s regime it was Iraqis—in the face of threats of violence from al Qaeda and home-grown insurgents—who went to the polls and, thanks to the extraordinary sacrifices of the American military and our diplomatic corps, began the long, hard work of creating the only functioning Arab democracy. All of which brings us to President Obama’s speech yesterday, where he said this:

Indeed, one of the broader lessons to be drawn from this period is that sectarian divides need not lead to conflict. In Iraq, we see the promise of a multiethnic, multisectarian democracy. The Iraqi people have rejected the perils of political violence in favor of a democratic process, even as they’ve taken full responsibility for their own security. Of course, like all new democracies, they will face setbacks. But Iraq is poised to play a key role in the region if it continues its peaceful progress. And as they do, we will be proud to stand with them as a steadfast partner.

In just a few years, then, Iraq has, for Barack Obama, gone from a strategic disaster to something of a model for the region. His words sound very much like those of President Bush, who told the United Nations in 2003, “Iraq as a dictatorship has great power to destabilize the Middle East. Iraq as a democracy will have great power to inspire the Middle East.”

The fact that Barack Obama is now (belatedly) embracing the views of his predecessor is something to be grateful for. To have a liberal, Democratic president declare that Iraq shows “the promise of a multiethnic, multisectarian democracy” and is “poised to play a key role in the region” is a very good thing for our country and the wider Middle East. And it will help to heal the divisions caused by the war.

But even in this moment of unity it is worth considering, even for a moment, the fact that if Barack Obama had had his way, Iraq would still be an enemy of America, led by a barbaric dictator with a fondness for war and for genocide. And if Obama’s counsel had been heeded after the war began, the surge would have been stopped and Iraq would now be convulsed by civil war, America would have left in defeat and disgrace, and al Qaeda—in the form of al Qaeda in Iraq—would have attained its greatest victory ever.

Obama will never in a thousand years be able to bring himself to credit George W. Bush for deposing Saddam, for challenging the pathologies within the Arab world, and for putting in place a new military strategy that led to a dramatic turn in fortunes of war. No matter; history has a way of taking care of such things.

In any event, the Iraq war was not, as people like Joe Klein repeatedly insisted, “probably the biggest foreign policy mistake in American history.” It was instead, in the words of the great Middle East scholar Fouad Ajami, “a foreigner’s gift.” It was a gift bequeathed to the Iraqis at a great cost to America. But it looks to be a gift that has been received and one that we can hope will, over time, help tame the furies of the Arab world. So sayeth Barack Obama.

Peter Wehner is a senior fellow at the Ethics and Public Policy Center.