John McCain struggled with limited funds compared with those of his rival
Candidate John McCain seemed to have it all.
Few in America did not know about his decades of service, his breath-taking heroism as a prisoner of war in Vietnam, his foreign policy expertise and his ability to reach across the Congressional aisle.
Mr McCain's opponent was largely untested, inexperienced and, initially at least, unknown; his race only added to his challenge.
If there is such a thing as a perfect political storm though, John McCain found himself caught in the middle of it. In a leaky boat. With limited fuel.
From the start, his biggest problem was finding the money to compete with Barack Obama's $650m (£403m) campaign juggernaut. By accepting federal funding (which Mr Obama declined) he capped his general election campaign spending at $85m (£53m).
Republican supporters: 'I love John McCain...I think he's awesome'
Of course much more than that was spent by the Republican National Committee and other pro-McCain groups, but Mr McCain could never seriously challenge Mr Obama's ability to dominate the TV airwaves - even in states that were traditionally Republican.
Worse, Mr Obama had the money to force him to compete in states he should have been able to rely on, which reduced the amount of money Mr McCain had for states he needed to target.
His other big problem was in trying to separate himself from one of the most unpopular presidents in American history.
As a mostly loyal Republican, his record was one of support for President George W Bush, which Barack Obama never let him forget.
Mr McCain insisted that he would be a very different president, without explicitly rejecting George Bush's presidency. Instead he tried to position himself as a maverick who had gone his own way in the past.
But conservative Republicans knew all too well that "maverick" also meant going against them on issues such as immigration and campaign finance reform.
The right-wing, evangelical Republicans who had got Mr Bush elected were unhappy about Mr McCain from the start. That forced him into selecting a vice-presidential candidate who would reassure them.
Governor Sarah Palin of Alaska was a huge gamble from the start.
Mr McCain had said that the only thing he would look for in his vice-president was the ability to be president. Given that he would have been the oldest first-term president in history, that seemed particularly relevant.
But choosing someone with no national experience and no foreign experience as his running mate raised questions about his judgement and undermined his main argument against Mr Obama.
Sarah Palin made it difficult for John McCain to broaden his appeal
In the few interviews she gave, it was clear that she had not grasped foreign policy issues to the same extent as anyone she was running against. But there were other problems too.
She was the subject of an ethics probe in Alaska which eventually ruled that she had abused her power. Then came questions about her official expenses and her claims to have tried to end wasteful federal construction projects.
Her "hockey mom" persona was undermined by a revelation that the campaign had spent $150,000 on clothes and accessories for her.
As the weeks went on, her poll ratings fell heavily. She may have helped shore up the Republican base but she made it far more difficult for Mr McCain to broaden his appeal - especially with her forceful views on abortion and the environment.
She also helped drive away some in her own party. Mr Bush's former Secretary of State Colin Powell cited her as one of the reasons he had decided to endorse Mr Obama; he decried what he saw as an increasing "narrowness" of the party.
He also condemned the negative attacks on Mr Obama coming from the McCain campaign as having gone too far.
This was another aspect of the McCain strategy that seemed to backfire. Although Mr McCain ran only 10% more purely negative adverts than his rival, according to media monitoring groups, they were more deeply personal attacks - accusing Mr Obama of having a close relationship with a "domestic terrorist", for example.
Such ads created a backlash from independent voters, according to the polls, and Mr McCain was forced to change his tone.
Mr McCain could not match the appeal of his younger opponent
In fact, he could never quite find a narrative that worked. He went from being war hero, to the voice of experience, to maverick, to tax-cutter, but he never found a way to lift himself in the polls.
His team hoped the three presidential debates would finally reveal their candidate to be best qualified for the job. But in the "town hall" setting Mr McCain favoured, he wandered around the stage and forgot that what may work in a real town hall doesn't necessarily work with a TV audience.
In other debates he tried confronting Mr Obama, but was never able to shake the younger man's almost unnatural cool. At times, Mr McCain seemed to be trying to keep a simmering rage under control, which brought more negative coverage.
When the credit crisis erupted and the economy stalled, it seemed a damning indictment of an era of Republican deregulation and "trickle-down" economics.
Mr McCain's past quotes about the fundamentals of the economy being strong came back to haunt him. His tax plan - which seemed to favour the wealthy - rang hollow with people facing foreclosure and job losses.
His abrupt suspension of his campaign to return to Washington and "fix the problem" seemed erratic and was ultimately ineffectual.
In the end, he projected an image as a man from America's past, who had been through much and served his country well.
But in a disgruntled nation, deeply disenchanted with Republicanism, he couldn't match the appeal of his younger opponent and his message of change.
This page is best viewed in an up-to-date web browser with style sheets (CSS) enabled. While you will be able to view the content of this page in your current browser, you will not be able to get the full visual experience. Please consider upgrading your browser software or enabling style sheets (CSS) if you are able to do so.