Fred Cherry, an Air Force fighter pilot, was downed by enemy fire over North Vietnam in 1965, and he spent more than seven years a prisoner of war.

He had grown up in the Jim Crow South, and his captors made it clear he could mitigate the harshness of his incarceration, including routine torture, and improve his living conditions by speaking out against the racial injustice and discrimination that he had faced as an African American in the United States.

When beatings failed to bring him around, his jailers tried another tactic. They assigned a self-described "Southern white boy" as his cellmate, hoping that racial antipathy between the two men would weaken his resolve and produce a propaganda triumph for North Vietnam.

The plan failed.

Instead, the two men, Cherry and a Navy fighter pilot, then-Ensign Porter Halyburton, became fast and lifelong friends. Each would credit the other with having saved his life.

Cherry died Feb. 16 at a hospital in Washington. He was 87. The cause was heart ailments, said his companion of 24 years, Deborah Thompson.

He was a major when he was taken prisoner and had more than 100 combat missions in Korea and Vietnam behind him on the day — Oct. 22, 1965 — that his F-105 Thunderchief fighter-bomber was hit by enemy antiaircraft fire.

"The plane exploded and I ejected at about 400 feet at over 600 miles an hour," Cherry wrote in a 1999 collection of war stories by POWs and Medal of Honor recipients. "In the process of ejection, I broke my left ankle, my left wrist, and crushed my left shoulder. I was captured immediately upon landing by Vietnamese militia and civilians."

"I spent 702 days in solitary confinement," he added, with the longest period lasting 53 weeks. "At one time I was either tortured or in punishment for 93 straight days."

Early in his captivity Cherry was matched with Halyburton, a North Carolinian who had been shot down Oct. 17, 1965. For eight months they would live together. But whatever mutual animosity their captors may have hoped for never materialized.

"I guess they thought if they had a Southern white boy taking care of a black man it would be the worst place for both of us," Halyburton said in a telephone conversation from North Carolina. "It turned out to be the best thing that ever happened to me."

For eight months, he changed dressings on his cellmate's infected wounds, fed him, bathed him, and watched over him. "He said I saved his life, and he saved my life. ... Taking care of my friend gave my life some meaning that it had not had before."

The two men lived in a succession of fetid 10-by-10-foot cells, sleeping on straw mats, benches or the floor.

"I was so inspired by Fred's toughness," Halyburton said. "He had grown up in the racial South (and) undergone a lot of discrimination and hardship. But he was such an ardent patriot. He loved this country. It inspired me, and it inspired a lot of others."

For 2,671 days, Cherry was held in captivity before his release on Feb. 12, 1973, with the first group of U.S. prisoners of war to come home.

Fred Vann Cherry Sr. was born in Suffolk, Virginia, on March 24, 1928. His parents were farmers. He attended racially segregated public schools and graduated in 1951 from Virginia Union University, a historically black college in Richmond.

He then joined the Air Force and during the Korean War flew more than 50 combat missions over North Korea.

In the summer of 1966, after eight months of sharing a cell, Cherry and Halyburton were separated. Halyburton remembers it as "one of the saddest days of my life." They did not see each other again until 1973, when they met at a military hospital at Clark Air Base in the Philippines following their release from captivity.

Cherry, who later attended the National War College and the Defense Intelligence School in Washington, retired from the Air Force in 1981 as a joint staff officer assigned to the Defense Intelligence Agency. He was a resident of Silver Spring, Maryland.

His medals included the Air Force Cross, awarded, according to the citation, for "extraordinary heroism in military operations against an opposing armed force as a Prisoner of War ... extremely strong personal fortitude and maximum persistence in the face of severe enemy harassment and torture, suffering critical injuries and wounds."

But Cherry's homecoming was painful. His wife, the former Shirley Brown, reportedly deserted him soon after he went missing, cleaned out his life savings and bore a child with another man. The officer endured years of legal proceedings and negotiations with the military over issues involving back salary, child-support payments and allowances.

Survivors include his companion, of Silver Spring; four children from his marriage, Deborah Cherry-Jones and Donald Cherry, both of Norfolk, Virginia, Cynthia Cherry-Leon of Woodbridge, Virginia, and Fred Cherry Jr. of Springdale, Maryland.; a son from another relationship, Frederick Stein of Los Angeles; 14 grandchildren; and six great-grandchildren.

Cherry and Halyburton, who retired from the Navy at the rank of commander, gave joint talks at military institutions and colleges. In 2004, they toured to promote a book about their story, "Two Souls Indivisible: The Friendship That Saved Two POWs in Vietnam," by James S. Hirsch.

Cherry was also featured in a public television documentary narrated by Tom Hanks, "Return With Honor," about Vietnam fighter pilots held as POWs.

"I know that the faith in God, love and respect for my fellow man that my parents and family instilled in me during my youth carried me through some very difficult years as prisoner-of-war in Vietnam," Cherry wrote in the 1999 collection of POW war stories.

"I was always taught to love and respect others and forgive those who mistreat, scorn or persecute me. ... (This) allowed me overcome the damages of discrimination, Jim Crow, and the social and economic barriers associated with growing up a poor dirt farmer. ... My standard for making decisions is based on doing what is right."