On Tuesday, dodging the hubbub of election parties, I watched the results come in with two close friends and my teenage daughter. We might have been patients showing up at a hospital for a surgical procedure, nervously joking over the early returns from Vermont (predictably, Barack Obama) and Kentucky (predictably, John McCain). When, at 8:01pm, Pacific time, CNN called the race for Obama, we collapsed in one another's arms. Even my dry tear ducts did their job, and, for a few moments, the room swam out of focus. The champagne, whose presence in the fridge I had thought to be ominously bad karma, was opened. No toast. Just "Thank God, thank God, thank God", spoken by four devout atheists. There was little triumph in our emotion, only an overpowering wave of relief that, after eight years of manic derangement, America had at last come to its senses.

Inevitably, Wednesday's headlines were all about Obama's skin colour and the historic milestone of the first black presidency. For the United States and the rest of the world, that is a fact of huge symbolic importance, but it is the least of Obama's true credentials. What America has succeeded in doing, against all the odds, and why we cried when it happened, is to elect the most intelligent, canny and imaginative candidate to the presidential office in modern times - someone who'll bring to the White House an extraordinary clarity of thought and temperate judgment.

Every White House has had its intellectuals, but very few presidents have been intellectuals themselves - Thomas Jefferson, John Adams, Woodrow Wilson, the list more or less stops there. Much of the nightmare of the last eight years has arisen from the fact that one of the least intellectually curious or gifted presidents in history was in thrall to a group of passionate, but second-rate, neoconservative intellectuals, all associated with the Project for the New American Century (PNAC), whose imperial agenda for the US was lost on the man they guided and advised. Richard Perle, Paul Wolfowitz, Douglas Feith, the architects of the war on Iraq and the "war on terror", were treated by George Bush as experts on parts of the world of which he was ignorant. "Wolfie" knew all about the Middle East; that this knowledge proceeded from a hardline political philosophy instilled in him by Richard Pipes of Harvard and Albert Wohlstetter of the University of Chicago, both avid cold warriors and proponents of US military, political and cultural domination of the globe, was grasped, if at all, only very dimly by the 43rd president, who prided himself in reading no newspapers and being in bed by nine. While Bush was bicycling and cutting brush at his Crawford ranch in Texas, the intellectuals in his administration were staying up late in DC, busy about the task of reshaping the United States into the Roman Empire of the 21st century.

Since September 11 2001, the damage inflicted by intellectuals on America and its constitution and justice system, as well as on the outside world, has been so great that we ought to be wary of the election of an intellectual to the presidency, and, though he tried his best to veil his proclivities while on the stump, Obama is an intellectual. At the University of Chicago, he taught constitutional law, the most demanding and far-reaching area of study in US law schools. He names Philip Roth and EL Doctorow among his favourite living writers. In his memoir Dreams From My Father, the late-night life he describes himself as leading inside his own skull is every bit as real and vivid as the exterior life he records on the streets and in the homes of Honolulu, Jakarta, New York, Chicago and Kenya. Again and again in that book, one finds Obama in the small hours, reconstructing in his mind recent events, searching for patterns, making connections, a novelist teasing meaning and significance from the chaotic stream of daily contingencies.

Dreams From My Father reveals more about Obama than is usually known about political leaders until after they're dead. Perhaps more than it intends, it shows his mind working, in real time, sentence by sentence, in what feels like a private audience with the reader. The self at the centre of the book is, above all, an intent watcher and listener - one of those on whom, as Henry James said of the ideal writer, nothing is lost - and there runs through the story an almost worshipful regard for what Obama calls "the messy, contradictory details of our experience".

The unique contradictions and messinesses of his own childhood made him an empiricist by instinct, finding a path for himself by testing his footing each step of the way. His education at Columbia and Harvard made him an empiricist by training. As a law professor at Chicago, he pressed his students to adopt contrarian views while playing his own opinions close to his chest. In July this year, the New York Times reported:

Obama liked to provoke. He wanted his charges to try arguing that life was better under segregation, that black people were better athletes than white ones. "I remember thinking, 'You're offending my liberal instincts," a former student remembered.

In the Illinois state senate as well as in the US Senate, this has been his habit as a legislator, to solicit counter-arguments against his own position, to deploy his unusual talent as a close and sympathetic listener, to probe, to doubt, to adapt, to change.

Such chameleonic powers are liabilities on the American campaign trail, where constant iteration of simple maxims ("Drill, baby, drill!" or "Read my lips: no new taxes") is required, and any variation of policy is derided as a "flip-flop", but Obama the chameleon has conformed to the rules of this game, too. It's only now that we can expect to see the full extent of his natural flexibility of mind.

During the last two years he has been quietly surrounding himself with other intellectuals. Two are law professors: Cass Sunstein of Chicago and Laurence Tribe of Harvard, who taught Obama there and called him "the most impressive student I'd ever worked with".

There's Austan Goolsbee, Obama's senior economic adviser, from the business school at Chicago, a highly eclectic behavioural economist, who writes about the dismal science with both impressive clarity and sceptical humour. Funny economists are in lamentably short supply: Goolsbee has moonlighted as a stand-up comedian.

This growing coterie of wits and scholars looks a lot like the "brain trust" which Franklin Roosevelt assembled in 1932 to shape the New Deal. Happy in the company of prominent intellectuals, and with a mind equal to theirs, Obama promises to spectacularly raise the IQ and the standard of debate inside the White House (unlike John Kennedy, who liked intellectuals as ornaments of his administration, but never seriously engaged their talents).

Heaven knows, he will need all the intelligence and range of viewpoints he can muster to cope with the toxic legacy he inherits from the 43rd president: the mounting turmoil in Afghanistan, the dangerous, simmering cauldron in Iraq; an America cordially loathed by at least half the world; an impending global economic catastrophe, triggered by the lunatic improvidence of deregulated Wall Street. Not since Lincoln and Roosevelt has an incoming president been landed with an America in such desperate need of rehabilitation and repair, and it was no surprise that, in his Chicago victory speech on Tuesday, Obama conjured the ghosts of those two presidents.

Early in the campaign, he was painted as an empty optimist - a description that couldn't be more wrong. For every rousing "Yes, we can!", there was the caveat of "It won't be easy", and, uniquely among the raft of candidates in the primaries, Obama brought to the election a clear-sighted grasp of the tragic aspect of US history. His most uplifting speeches were grounded in images of the shame of slavery, the national agony of the civil war and the intimate humiliations of poverty in America, and it was by reminding his audiences of the depths to which the country is prone to sink that he was able to summon them to hope.

On Tuesday, there was a strong echo of Roosevelt's first inaugural speech when Obama said, "I will always be honest with you about the challenges we face. I will listen to you, especially when we disagree."

After eight years of an administration whose hallmarks have been secrecy, dishonesty, and a refusal to listen to any voice outside its own inner circle, this promise of candour and conversation was probably the most important policy statement that he could make as president-elect.

If there is one prediction that one can make with near-certainty, it is that, by January 20 2009, inauguration day, things will be rather worse than they are now, at least in Afghanistan and on the economic front, on which ever more dismal results and forecasts continue to roll in. Yet the worse the crisis, the more latitude it will allow the new administration in showing its intellectual mettle quickly and decisively, and it's to be assumed that, even now, Obama is talking with Goolsbee, Paul Volcker, Lawrence Summers, Jason Furman, Warren Buffett and his other on-tap economic advisers, in an extended seminar on the financial meltdown and its possible solutions. The best thing about living in the United States since Tuesday has been the gilt-edged assurance that, somewhere out there, very smart people are thinking and talking in a serious conversation from which narrow ideologues have been rigorously excluded.

We've elected as president someone who is empirical, cautious, conservative with a small "c", yet unusually sure of his own judgment when he makes it, which is often slowly. He's sure to disappoint those of his supporters who believe he can raise the dead, turn water into wine, and walk on water. But he has rescued the White House from the besotted rationalists of PNAC with their Platonist designs on the world, and restored it to the realm of common reason. It's a measure of the madness of the last eight years that, for this seemingly modest contribution to the nation's welfare (and not just this nation's), grown men and women wept in gratitude on Tuesday night.