Image copyright Getty Images

Born on the eve of World War Two, John McCain came of age with the dawn of the US as a global superpower.

His lifetime spanned an arc across what Henry Luce once predicted would be the American Century - a time when US political, military and cultural power was unrivalled across the globe.

He fought in Vietnam and suffered the ravages of captivity as the US itself was wracked by doubt and anger over an inability to achieve victory in South-East Asia.

He became a rising star in US politics, only to nearly succumb to the temptations and corruptions of money and influence in American democracy.

He mounted an anti-establishment presidential campaign that presaged the anger and longing for authenticity that would later sweep through US politics.

He won the Republican presidential nomination as that fervour began to curdle, turning against him and the established order in his party.

In McCain's last days, he offered a full-throated defence of the idea that an internationalist, engaged American nation could serve as a guide to friends and a bulwark against foes - and railed against the man, Donald Trump, who campaigned against this world view.

McCain exits the stage at what is, perhaps, the twilight of the American century, when the nation has focused inward, concerned about potential dangers of immigration, the entanglements of multilateralism and the challenges of a global economy.

Here are six moments of McCain's life that reflect the American history he lived through.

Released from prisoner of war camp

14 March 1973

The image is striking. A gaunt McCain, aged 36, dressed in rumpled civilian clothes, marching along with fellow American prisoners of war to a US military transport plane that would take them to freedom.

More than five years of captivity in a Vietnam prison had aged him. McCain's hair had been dark when his jet was shot down by a surface-to-air missile during a mission over Hanoi. Now it was grey and white.

He walked with a limp - the product of injuries sustained from ejecting from his damaged plane, as well as torture at the hands of his Vietnamese captors. At a White House reception a month later with President Richard Nixon, McCain relied on crutches to walk.

He never fully recovered from his wounds. The limp would mostly disappear, but for the rest of his life he was unable to raise his arms above his head.

Image copyright Alamy

Political consultant Mark McKinnon, who advised McCain during his 2008 presidential run, describes helping brush the candidate's hair while they were waiting behind a van together before a public event in New Hampshire.

"It was just a vulnerable moment of this proud soldier," he said. "And so I combed his hair, and he left to walk into the crowd. I turned away and just wept."

Although McCain would remain in the military for eight years after his return to the US, the day of his release from Vietnam marked the pivotal moment of a military career that was seemingly ordained from birth.

Both his father and his grandfather were Navy admirals, the latter commanding a carrier group that fought against Japan in World War Two

McCain followed in their footsteps, attending the US Naval Academy, where friends said he sometimes struggled with the military tradition he was expected to follow.

"He felt like he didn't have a choice," says Frank Gamboa, one of McCain's roommates when the two men were midshipmen at the US Naval Academy. "One of the burdens of having a family legacy is you can't be your own self."

Throughout his time at the academy, McCain rebelled. He earned the nickname "John Wayne" McCain for his attitude and popularity with the opposite sex. He collected demerits the way some people collect stamps. He seemed perennially on the verge of failing out of school, and graduated near the bottom of his class.

McCain did occasionally use his family background as a shield. Gamboa describes one instance where McCain upbraided a senior classmate for being abusive to a Filipino steward during dinner - a bit of insubordination that could have landed him with a disciplinary report.

When the man asked for his name, McCain replied: "John S McCain III. What's yours?" Upon hearing the name, according to Gamboa, the man skulked off.

As a prisoner of war McCain had another opportunity to use his family name to avoid trouble - and declined. When his captors learned he was the son of an admiral, he was offered early release. McCain refused - insisting that those who were captured before him should go first.

"The interrogator told McCain things certainly are going to go very bad for you," Gamboa says. "And that's when they started torturing him. It was a momentous and courageous decision to literally turn down freedom for the sake of his fellow POWs."

McCain would spend years in solitary confinement, being tortured by the Vietnamese. He would eventually relent and sign a "confession" he had committed war crimes. He never sought or received special treatment because of his parentage, however, and when he left Vietnam he did so with his fellow prisoners.

Elected to Congress

2 November 1982

McCain made his entry into politics by winning an open seat in a reliably Republican Phoenix-area US congressional district. He had moved to Arizona shortly after marrying his second wife, Cindy, and spent some time working for her father, a wealthy Phoenix businessman, where he made the kind of influential connections that would help support his congressional bid.

"I was not at all surprised that he went into politics," Gamboa says. "He had no more career left in the Navy. He wasn't going to get the assignments that he would need to make admiral, so remaining as a captain until retirement was not in his interests."

The highlight of his first campaign was a Republican primary debate, when one of his opponents questioned McCain's ties to his newly adopted home state.

McCain, his temper flashing, shot back.

"Listen, pal, I spent 22 years in the Navy," he said. "My grandfather was in the Navy. We in the military service tend to move a lot. We have to live in all parts of the country, all parts of the world. I wish I could have had the luxury, like you, of growing up and living and spending my entire life in a nice place like the first district of Arizona, but I was doing other things. As a matter of fact, when I think about it now, the place I lived longest in my life was Hanoi."

McCain would go on to win the primary by 6% over his nearest competitor. He would win more than double the votes of his Democratic opponent in the November general election.

In his 2002 memoir, McCain said that he thought his debate performance won the election - although it wasn't part of a grand campaign strategy.

"I was just mad and had taken a swing," he wrote.

McCain arrived as a freshman congressman in Washington with strong connections already in place. Prior to leaving the armed forces, he had served as Navy liaison to Congress and had forged ties with politicians and staffers in the Capitol. It was the same position McCain's father held when McCain was a teenager.

But McCain "was always different," says biographer Elizabeth Drew. "He was different in the prison camp and different in Congress."

While his record in the House was fairly conventional, "he was never just one of the boys," Drew says. "There were pictures all over the place of this man, bedridden in a prison camp, so he always stood out from your run-of-the-mill politicians."

McCain was elected president of his congressional class. On one of his first high-profile votes, he broke with his party and president, Ronald Reagan, in opposing a US military deployment to Lebanon - a position that would be vindicated just a month later, when 241 US Marines and 58 French soldiers were killed in a suicide attack on their military compound.

Image copyright Getty Images Image caption McCain went back to Vietnam several times, including here in 1992

In his second term, he landed a plum position on the House Foreign Affairs Committee. In 1985 he would return to Vietnam with legendary CBS television presenter Walter Cronkite, where he posed for photographs by a monument to the anti-aircraft battery that shot down his plane.

A US political magazine labelled him a "Republican on the rise".

A year later, he would run for, and win, a seat in the US Senate from Arizona. He replaced Barry Goldwater, the godfather of the US conservative movement and the Republican presidential nominee in 1964.

It was an office he held for the remaining 31 years of his life.

Cleared in corruption scandal

20 November 1991

One of the realities of American politics is that candidates and officeholders have to engage in a nearly endless effort to raise the funds necessary to run for office and win re-election.

It was a lesson McCain learned as he was courting Phoenix-area businessmen and wealthy donors prior to his first run for Congress. And it was one of those businessmen, banker and real-estate developer Charles Keating, who nearly destroyed McCain's political career.

The scandal that engulfed him grew out of the savings and loan crisis of the late 1980s, when a combination of lax financial regulation and business corruption led to the collapse of more than a thousand financial institutions. Keating feared his firm, Lincoln Savings and Loan, was being targeted for increased scrutiny from government regulators and in danger of failing.

He urged his friends in the US Senate - men whose campaigns he had supported - to convince federal officials to go easy on Lincoln. One of those men was McCain, who in addition to taking campaign contributions from Keating, had gone on several vacations to the Bahamas courtesy of the businessman.

McCain sat in on two meetings between senators and regulators to review the matter. The five senators, simply by their presence, showed regulators that Keating had powerful friends. McCain said he only wanted to make sure Lincoln was being treated fairly.

In the second gathering, McCain learned that Lincoln was being referred to the justice department for criminal prosecution. At that point, the Arizona senator dropped the matter - but he had held his hand close to the flame. It wasn't long before the whole matter went public, and McCain felt the heat.

Lincoln collapsed, US taxpayers were out more than $2bn in deposit insurance payments, and Keating was indicted and convicted of fraud. McCain and the other four senators in the meetings became the face of corrupt political influence and the corrosive effects of campaign contributions.

They were given a nickname, the Keating Five, and the Senate Ethics Committee opened an investigation into the matter.

After originally bristling at the scrutiny - snapping at reporters who questioned his actions - McCain changed tactics, holding press conferences and openly admitting he acted improperly. In the end, the Senate investigation largely exonerated McCain, finding only that he had shown "poor judgement" in the matter.

Media playback is unsupported on your device Media caption Cancer-hit Senator John McCain: To hell with loudmouths!

McCain would later call the Keating scandal a "hell of a mess" and an "asterisk" that would haunt his political career.

"This stayed by his name," says Drew, "and it bothered him a lot."

The senator would go on to make campaign finance reform one of his central legislative goals. His work would eventually lead to passage of a landmark bill in 2002 that curtailed the influence of unregulated donations to political party committees as well as limited political speech by independent groups. The latter provision would eventually be struck down by the Supreme Court.

Brooke Buchanan, who worked on McCain's 2008 presidential campaign and later served as communications director in his Senate office, says fund-raising was the part of politics McCain found particularly distasteful.

"That was something throughout his career, his view of money in politics and the corrosive aspect of it," she says. "He did not keep those opinions to himself."

South Carolina defeat

19 February 2000

In 2000, George W Bush was the establishment pick for the Republican presidential nomination - back when that actually meant something.

McCain almost won anyway.

The Arizona senator ran a low-budget, media-friendly campaign best known for the candidate's free-wheeling style, as he toured New Hampshire - a key early primary state - on a bus nicknamed the "Straight-Talk Express".

He won the state by 18 points, a stunning victory that sent the Bush campaign scrambling and set up an electoral showdown two weeks later in the South Carolina primary.

Image copyright Getty Images Image caption US Senator John McCain and his wife Cindy speak with reporters as they travel from Columbia to Sumter, South Carolina 07 Jan 2000

If McCain could post a win there, the veneer of inevitability that had insulated Bush would crumble, and ease McCain's path to the nomination. An earlier 50-point Bush national lead had vanished in the New England snow, and South Carolina was now a dead heat.

McKinnon, who worked on the Bush team in 2000, says McCain "just kicked our butts in New Hampshire".

It wasn't a mortal blow, however, and the Bush team made the decision to go negative on McCain and go hard. If their man was going to lose, he'd do it swinging.

On the record, Bush's supporters began criticising McCain's Senate voting record and attempting to undermine his reformer credentials. Their candidate adopted the slogan: "A reformer with results".

Off the record, things turned ugly. Rumours started spreading - fuelled by anonymously delivered pamphlets, emails and automated phone calls - that McCain had fathered an illegitimate, interracial child. (McCain and his wife had adopted a girl from Bangladesh, and her photograph was used in some of the material).

There were other elements of the whisper campaign - hushed questions about McCain's mental health, wild claims he was a "Manchurian candidate" programmed by his North Vietnamese captors, and rumours that he slept with prostitutes.

"It got really nasty," McKinnon says, admitting the Bush campaign knew there were third parties "doing all sorts of crazy stuff" but had no part in it. "It would have been a crime if we had co-ordinated."

McCain didn't help himself with South Carolina conservatives either, saying at one point that he believed the Confederate battle flag, which at the time flew over the state's capitol, was a "symbol of racism and slavery".

He later backed off that statement, calling the flag part of the South's "heritage", managing to disappoint both sides on a divisive topic.

He also criticised Bob Jones University, the South Carolina Christian college that prohibited interracial dating, where Bush had recently given a speech.

"McCain was not very good at cultivating evangelical support, and he thought they were intolerant," Drew says.

"He denounced them and their role in politics, which might have been correct, but it wasn't the political thing to do."

Image copyright Getty Images Image caption 'A reformer with results' appears on George W Bush campaign signs ahead of South Carolina's primary

When the Bush fusillade began, McCain's first response was to hit back. His campaign aired a television spot comparing Bush to then-President Bill Clinton - a move the then-Texas governor called "as low a blow as you can give". McCain would later order an end to his negative adverts after a woman at a town hall forum told him her son had become distraught after receiving a Bush campaign call that labelled the Arizona senator a liar and a cheat.

Bush ended up taking the South Carolina primary by 11 points. The Arizona senator would win a few more contests, but the well-financed and organised Bush machine regrouped and ground him down.

Those heady days after New Hampshire in 2000 were probably as close to the presidency as McCain came in his life. Bush, with a strong conservative tailwind, went on to defeat Al Gore later that year.

"If the campaign had ended in South Carolina a day or two earlier, McCain would have won," McKinnon says. "And he would have won the presidency."

McCain went back to the Senate and focused on passing campaign finance reform, biding his time until 2008, and making the kind of establishment connections to ensure his next bid for the presidency would begin from a position of strength.

Rejects Obama conspiracy theories

10 October 2008

By the time of McCain's trip to Lakeville, Minnesota, for the kind of town hall forum he'd been doing throughout the campaign, his 2008 presidential bid was in trouble. He was trailing in the polls, and the stock market was in freefall.

McCain's surprise pick for vice-president, little-known Alaska Governor Sarah Palin, was "going rogue" - lashing out at Democrats, questioning Obama's patriotism and accusing him of "palling around with terrorists".

She was giving voice to a Republican base growing increasingly unsettled and angry at the prospect of an Obama presidency after eight years of Republican rule. Some conservative talking heads and grassroots fringe groups were questioning Obama's citizenship, religious affiliation and eligibility to run for president.

It all came to a head at a high school gymnasium in Lakeville.

When one supporter said he was "scared" of an Obama presidency, McCain replied that the then-senator from Illinois was a decent person. The audience booed, as members of the crowd shouted that the Democratic nominee was a liar and a terrorist.

Then an older woman with frazzled white hair said she could not trust Obama, adding she had "read about him" and "he's an Arab". McCain shook his head and took the microphone back.

Image copyright Getty Images

"No, ma'am," McCain said. "He's a decent family man, citizen, that I just happen to have disagreements with on fundamental issues, and that's what this campaign is all about."

Brooke Buchanan, McCain's campaign press secretary, was standing by him at the Lakeland event and says she could tell it was a fiery atmosphere in the high school gym that day - and that McCain would probably pay a political price for his answer.

"We dealt with that the entire campaign because there is a Republican base who believed in that," Buchanan says. "But at that point it didn't matter. It wasn't the right thing, and it wasn't the way that Senator McCain wanted to run his campaign."

Over the course of the Obama presidency, the anger and resentment within portions of the Republican base that McCain had tried to confront in Minnesota grew more prominent. The party started to look more like Palin - a harbinger of Mr Trump's unvarnished conservative populism - and less like the Arizona senator.

"McCain was trying to carve out a new kind of Republican party, trying to move it to be a more centrist, forgiving kind of party," Drew says. "He was leading a movement to do it. But in the end, there were forces bigger than them."

'No' on Obamacare repeal

28 July 2017

It was the middle of the night when Brooke Buchanan's phone rang. It was McCain. She no longer worked for the senator, but the two still talked almost daily.

"Get up," he said. "Turn on your TV. We're going to be making some news."

The US Senate was considering whether to repeal portions of the Affordable Care Act, a comprehensive health-insurance regulation law that was Obama's signature legislative achievement.

The fate of the bill hung in the balance, as only one more "no" vote would kill the legislation and McCain was one of the few remaining undecideds. It was almost 1:30 in the morning.

Media playback is unsupported on your device Media caption Watch reactions to his "no" vote against repealing the Obama-era healthcare law

As Buchanan watched on her television, McCain walked out on to the Senate floor and turned to the clerk tabulating votes. He held out his right arm - the one that hadn't been repeatedly broken in Vietnam - and gave a quick thumbs-down.

"No," McCain said quietly, then sat down at his desk in the Senate chamber, as Republicans gasped and Democrats erupted in cheers. McCain - who had flown back from Arizona for the vote after undergoing emergency surgery for his recently diagnosed brain tumour - had bucked his party's leadership one last time.

He had defied President Trump, the man who had stunned Washington when he questioned McCain's heroism as a prisoner of war.

"I just had a huge grin on my face," Buchanan says. "I was proud of him for it. It was a tough decision to take, but again it was one of those times when the true McCain shined."

Buchanan says McCain voted no, in part, to allow other Republican senators who had misgivings about the repeal legislation, including his friend Lindsey Graham of South Carolina, to vote in favour and avoid angering the pro-repeal Republican base.

Image copyright Getty Images Image caption McCain on his way to the healthcare vote he would eventually kill

"He figured he had nothing to lose," she says.

It was McCain's most direct break with Mr Trump, but since then he stepped up his criticism. He denounced the president for striking a deferential tone with Russian President Vladimir Putin in Helsinki and the senator has condemned Mr Trump's attacks on the FBI and US intelligence services.

He also took swipes at him in a memoir released shortly before his death.

"The appearance of toughness, or a reality show facsimile of toughness, seems to matter more than any of our values," he wrote. "Flattery secures his friendship, criticism his enmity."

He also, according to the New York Times, told friends he did not want the president at his funeral - a final rebuke of the man who won the office McCain sought twice, but never achieved.

"I don't know if they've ever made them like McCain or they ever will," McKinnon says.

"He was great, but also vulnerable. He was not perfect, but he was the first one to admit that.

"He had low moments when he was a prisoner of war and low moments when he was in the Senate, but he never shied away from saying he was an imperfect human being, but at the end of the day it's my job to serve this country, and that's what he did."

.