A little over a month ago, the day after the vice-presidential debate when Joe Biden and Sarah Palin shadow-boxed on prime-time for an hour and a half, Barack Obama was sitting on his chartered campaign plane in Philadelphia, Pennsylvania, waiting to take off for his home in Chicago. He was weary and made no attempt to hide it. "I'm beat," he said. Though the polls showed he was ahead, he was taking nothing for granted, hence his appearance in a state he knew he had to win if he was to become the 44th incumbent of the White House.

Lately the campaign had turned ugly and much mud was being slung. John McCain, desperate to close the gap between himself and his much younger opponent, had named 44-year-old Sarah Palin as his running mate which, acknowledged Obama, had energised the conservative right. "And that's worth something in politics," he said. As ever, Obama seemed eager to demonstrate that he was no knee-jerk politician, ready to take advantage of an opponent's Achilles' heel. But he was also keen to stress he was no pussycat either. "Because I tend to be a pretty courteous person and I don't lose my temper," he said, "I think people underestimate my willingness to mix it up."

If anyone did underestimate him, they surely don't now. From the moment he announced his candidacy for the presidency in February 2007, Obama has come across like Jimmy Stewart in an old- fashioned western: straight-talking, honest, tough and, above all, principled. Though it's often said he's done nothing and that his lack of experience is his biggest drawback, he has shown throughout almost two years on the campaign trail that he has a spine of tungsten, initially coming from behind to see off Hillary Clinton to become the Democrats' nominee and then taking everything that the Republicans could throw at him and throwing it back with a vengeance.

How he achieved this is instructive. First, he put himself in the shop window by telling everyone who he was and where he came from and invited them to debunk him. His two books - Dreams From My Father and The Audacity Of Hope - may have been written before even political anoraks had him on their radar but they are clearly the work of a man of immense ambition. Towards the end of the latter, Obama described how of an evening in Washington he likes to run along the Mall, stopping first at the Washington Monument, then pushing on to the National World War II Memorial, the Reflecting Pool and Vietnam Veterans Memorial. Finally, he climbs the stairs of the Lincoln Memorial, where he reads the Gettysburg Address and the Second Inaugural Address, Lincoln's majestic peroration against slavery. "And in that place," he wrote, "I think about America and those who built it."

This, then, is the kind of company Obama aspires to keep. But ambition is one thing, achieving it another. In America, money talks and without it you're struck dumb. This has been the most expensive campaign in US history with around $2.4 billion spent by candidates. Of those, Obama spent by far the most. In the first three months of 2008 he raised more than $133 million. This bought a lot of air time, space in newspapers and a highly professional, motivated and well-paid backroom staff adept at manipulating the old and new media. Long gone are the days when Obama had to rely on favours from friends and the dedication of a handful of youthful employees who were willing to work long hours for peanuts.

From the outset, Obama appreciated he would be the subject of smears. This was brought home to him as early as 2001 in the aftermath of 9/11. "Hell of a thing, isn't it," a media consultant told him over lunch, as he and Obama looked at the front page of a newspaper on which there was a picture of Osama Bin Laden. "Really bad luck. You can't change your name, of course. Voters are suspicious of that kind of thing." In due course, much was made of Obama's close namesake and wild assertions were made, including the lie that Obama was a Muslim. Wisely, the Obama camp treated these with the contempt they deserved and the story died.

That showed savvy. Similarly, when his past came back to haunt him, in the guises of Pastor Jeremiah Wright, his spiritual mentor of 20 years, who preached: "God damn America," and Bill Ayers, who had history with a group that planted bombs and who once hosted a "coffee" for him, Obama acted quickly to distance himself. In the case of Wright, however, this was not done decisively enough. At first Obama said, "I can no more disown him than I can my white grandmother." But when the furore refused to die down, Wright was promptly disowned. By the time Ayers became an issue there was no such prevarication. Any attempt to connect Obama with events that happened when he was an eight-year-old child was "ridiculous" said the senator's spokesman.

All of which is simply part of the rough and tumble of the campaign trail. More troublesome for Obama, though, were the accusations that he, being Harvard-educated and able to string sentences together, was an elitist and out of touch with the likes of Joe the Plumber. Obama did not help his own cause when, while still trying to win the Democratic nomination, he suggested that when people are bitter they take refuge in guns and religion. Though he swallowed humble pie, his sentiments did not go down well with the very voters he was desperate to win over: the working class. That his remarks were made in Pennsylvania was doubly damaging. The comeuppance was a decisive victory in that primary for Hillary Clinton.

For Obama that was chastening. But it was something he had time to put right. Having previously failed to convince conservative, blue-collar white voters first time round, he devoted his considerable resources to rectifying that. And who better to enlist in that cause than Bruce Springsteen? To a soundtrack of Springsteen singing "come take my hand as we walk to the promised land" Obama laid into his rival for the presidency, deriding him for his U-turns on the economy. "He hasn't been getting tough on CEOs! He hasn't been getting tough on Wall Street! Suddenly a crisis comes along and the polls change and he's out there talkin' like Jesse Jackson. Come on!"

It proved a potent, unbeatable combination, Springsteen and Obama, rock-and-roll and old-fashioned, from-the-heart oratory. Pennsylvania, once thought out of reach, was Obama's, as indeed was America.