McCain's experience as POW shaped lifelong opposition to torture He became an outspoken critic of CIA "enhanced interrogation techniques."

During the Vietnam War, John McCain, then a 31-year old Navy pilot, was shot down in his plane over North Vietnamese territory, leading to five brutal years of captivity as a prisoner of war.

The torture McCain endured at the hands of his captors produced lifelong physical effects, including the inability to raise his arms above his head and a slight limp.

His experience also notably shaped his opposition to the CIA’s use of waterboarding and other “enhanced interrogation techniques” while in Congress.

As recently as May, McCain opposed the Trump administration’s nomination of Gina Haspel for CIA director, citing her leadership roles at the CIA at the time when the agency was carrying out the controversial program.

In a statement, McCain said he believed Haspel was a “patriot who loves our country and has devoted her professional life to its service and defense.”

“However,” McCain continued, “Ms. Haspel’s role in overseeing the use of torture by Americans is disturbing. Her refusal to acknowledge torture’s immorality is disqualifying.”

Haspel was ultimately confirmed as CIA director on May 17. McCain, still undergoing treatment for brain cancer as his home in Arizona, was not present for the Senate’s vote.

Understanding how McCain suffered as a POW provides a direct lens as to how he became such a strong advocate against the use of torture. Details of that account were taken from an interview he gave with U.S. News shortly after his release from captivity, as well as Robert Tinberg’s book, The Nightingale’s Song, which recounts the Vietnam experiences of five U.S. Naval Academy graduates including McCain.

Becoming a POW: “Dying was not his plan”

On Oct. 26, 1967, McCain was part of a 20-plane mission to bomb a power plant in Vietnam’s northern city of Hanoi. But in the midst of the mission, a surface-to-air missile struck his A-4 Skyhawk aircraft, taking off the plane’s right wing and forcing him to eject.

The sheer force of the ejection broke his right leg and both arms, briefly knocking him unconscious before he landed in a small lake. Burdened with heavy equipment, he sank to the bottom and had to kick to the surface for gulps of air.

Eventually, McCain used his teeth to activate his life preserver. But once on the surface, he was pulled ashore by a group of North Vietnamese who proceeded to attack him, tearing at his clothes and slamming a rifle butt into his right shoulder, shattering it. The group also bayoneted McCain in the abdomen and foot.

Over the next few days, he “lapsed from conscious to unconsciousness” while the North Vietnamese interrogated him, he said.

“I refused to give them anything except my name, rank, serial number and date of birth,” McCain told the U.S. News reporter.

His captors initially refused to provide McCain any medical treatment, but that all changed after they discovered that his father was a U.S. Navy admiral. Soon, several high-ranking North Vietnamese officers came to observe McCain in prison, and Vietnamese surgeons operated on his broken leg -- damaging several ligaments in the process.

After the medical treatment, McCain was transferred to a prison camp known as “The Plantation,” joining two captured U.S. Air Force majors, George “Bud” Day and Norris Overly.

“I was just astounded at his condition,” Day told ABC News in 2008 about McCain’s arrival to the camp. “I took one look at him and mentally said to myself, ‘They’ve dumped this guy on us to die so they can blame it on our neglect.’”

“He was emaciated,” Day continued. “His eyes really had that fevered bright death look. He stunk. He just hadn’t been washed or cleaned since I had no idea when.”

Day estimated that 5-foot-9 McCain weighed just 95 to 105 pounds.

“I never expected him to make it through the night. But he did,” he said. “Dying was not his plan.”

Solitary confinement and torture: “Every man has his breaking point”

McCain was moved into solitary confinement in March 1968. Several months later, his father was named the commander of all U.S. Pacific forces.

Hoping to capitalize on his father’s promotion, the North Vietnamese offered McCain an early release from prison, but he repeatedly refused, saying he would only accept the offer if every American captured before him was released as well.

Five months later, in August 1968, the torture began.

“For the next four days, I was beaten every two or three hours by different guards. My left arm was broken again and my ribs were cracked,” McCain said, according to U.S. News.

The North Vietnamese wanted a confession for crimes committed against their people. After four days of torture, McCain, reportedly at the point of suicide, agreed to write a confession.

“I felt just terrible about it,” he told U.S. News, adding, “Every man has his breaking point. I had reached mine.”

Years later, McCain would face critics who alleged that he gave the North Vietnamese information while he was POW, but those accusations have been debunked. On the contrary, McCain has recounted stories of lying to his interrogators under torture, including giving them the names of the Green Bay Packers' offensive line instead of the names of his own squadron.

McCain said that the treatment he and his fellow POWs received toward the end of 1969 became more tolerable, with his own torture ending around October. He was finally taken out of solitary confinement in March 1970, but would remain in captivity for another three years.

The Vietnam War ended upon the signing of the Paris Peace Accords on Jan. 27, 1973. Nearly two months later, on March 14, 1973, McCain would finally become a free man.

After captivity

Following nine months of rehabilitation, McCain attended the National War College, ultimately becoming the commanding officer of the Replacement Air Group, a training squadron out of Jacksonville, Florida.

He would go on to serve as the Navy’s liaison officer to the Senate -- his last assignment before retiring at the rank of captain in 1981 with 17 awards and decorations for his service.

The following year, McCain was elected as the representative for Arizona’s 1st Congressional District. He would serve in the United States Congress for the next thirty-six years.

ABC News’ Sarah Kolinovsky and Mariam Khan contributed to this report.