The prisoner of war had been tortured for 10 months and beaten repeatedly by his North Vietnamese captors in recent days, and there were threats of more if he did not respond properly when the propaganda broadcast began. Haggard but gritty, Cmdr. Jeremiah A. Denton Jr. slumped in a chair before the television cameras.

Pretending to be blinded by the spotlights, he began blinking — seemingly random spasms and tics. He answered interrogators’ questions with a trace of defiance, knowing he would be beaten again and again, but hoping that America would detect his secret message in Morse code.

To a question about American “war atrocities,” the captured pilot said: “I don’t know what is happening in Vietnam because the only news sources I have are North Vietnamese. But whatever the position of my government is, I believe in it, I support it, and I will support it as long as I live.”

The North Vietnamese, who lost face, were even more outraged when they learned that Commander Denton, in the Japanese-taped interview broadcast on American television on May 17, 1966, had blinked out “T-O-R-T-U-R-E.” It was the first confirmation that American prisoners of war were being subjected to atrocities during the Vietnam War.

The commander was beaten all night.

Mr. Denton, who returned home after seven years as a prisoner and became a rear admiral and a United States senator from Alabama, died on Friday at Sentara Hospice House in Virginia Beach, his son, Jeremiah A. Denton 3rd, said. He was 89.

Mr. Denton called himself “an average product of Middle America,” but his story was anything but ordinary — a war hero appalled by what he called America’s moral degeneracy, a crusading spokesman for right-wing Christian groups, a one-term Republican senator in the patriotic matrix of President Ronald Reagan. It was a political life shaped by indelible experiences in Vietnam.

On July 18, 1965, Commander Denton, leading a squadron of 28 A-6 Intruder attack jets and flying his 12th mission over North Vietnam, took off from the aircraft carrier Independence in the South China Sea. His bombardier-navigator was Lt. Bill Tschudy, and the target was a complex of military warehouses at Thanh Hoa, 75 miles south of Hanoi.

As he came in over the heavily defended Thanh Hoa Bridge on the Ma River, antiaircraft batteries opened up. Shells riddled the Intruder, knocking out its sophisticated guidance system. The aircraft went into a tailspin, and pain shot through the commander’s left thigh; a tendon had ruptured as he desperately tried to regain control, but it was hopeless. The fliers bailed out and were captured.

“Dazed and bleeding as I was, my principal emotion was fury,” Mr. Denton recalled. “I was mad as hell at being shot down, and even angrier at being captured.”

Over the next seven years and seven months, Commander Denton was held in various prison camps, including the notorious “Hanoi Hilton,” and endured beatings, starvation, torture and more than four years of solitary confinement, including periodic detentions in coffinlike boxes. He and other officers nevertheless maintained a chain of command and a measure of discipline among the prisoners.

“I put out the policy that they were not to succumb to threats, but must stand up and say no,” he told The New York Times in 1973. “Figuratively speaking, we now began to lie on the railroad tracks hoping that the sheer bulk of our bodies would slow down the train. We forced them to be brutal to us.”

The commander was often punished for urging others to resist. He also devised ways for prisoners to communicate by signs or numbers, tapping on a wall or coughing signals in a sequence. Ten months after his capture, he was selected for a propaganda interview to be broadcast on Japanese television.

It became famous after it was discovered that he had tricked his captors and blinked out the Morse code message that exposed North Vietnam’s brutal treatment of prisoners of war.

During his captivity, Commander Denton was awarded the Navy Cross and promoted to captain. In 1973, after President Richard M. Nixon announced a Vietnam peace agreement, Captain Denton was in the first group of prisoners released. “We are honored to have had the opportunity to serve our country under difficult circumstances,” he said at Clark Air Base in the Philippines.

His ordeal in Vietnam was graphically chronicled in a 1976 memoir written with Ed Brandt, “When Hell Was in Session,” and made into a 1979 NBC television movie starring Hal Holbrook and Eva Marie Saint.

In the book, he described an ordeal under torture. “A special rig was devised for me in my cell,” he recalled. “I was placed in a sitting position on a pallet, with my hands tightly cuffed behind my back and my feet flat against the wall. Shackles were put on my ankles, with open ends down, and an iron bar was pushed through the eyelets of the shackles.

“The iron bar was tied to the pallet and the shackles in such a way that when the rope was drawn over a pulley arrangement, the bar would cut into the backs of my legs, gradually turning them into a swollen, bloody mess. The pulley was used daily to increase the pressure, and the iron bar began to eat through the Achilles tendons on the backs of my ankles. For five more days and nights I remained in the rig.”

Promoted to rear admiral, he was named commandant of the Armed Forces Staff College in Norfolk, Va., a post he held until his retirement in 1977. Dismayed by what he regarded as a widespread failure of morality in America — from adolescent promiscuity to political disunity and disrespect for authority — Mr. Denton, in 1977, established the Coalition for Decency, dedicated to family values and good citizenship.

A Roman Catholic, he also became a consultant to the Christian Broadcasting Network and to his friend Pat Robertson, founder of the Christian Coalition, and began lecturing on domestic and foreign affairs, voicing support for the military services and for the contra rebels in Nicaragua.

In 1980, capitalizing on his war-hero image and running on a platform of strong national defense, he was elected to the Senate, defeating the Democrat, James E. Folsom Jr. He was Alabama’s first Senate Republican since Reconstruction and the first former admiral elected to the Senate. He served from 1981 to 1987, compiling a solid conservative voting record. He lost his bid for re-election in 1986 to Richard C. Shelby, a Democratic congressman who later became a Republican and who continues to hold the Senate seat.

Jeremiah Andrew Denton Jr. was born in Mobile, Ala., on July 15, 1924, one of three sons of Jeremiah and Irene Steele Denton. His father, a hotel clerk, moved the family often and the boy attended 13 elementary schools. In 1936, his father left the family, which returned to Mobile, and the parents were divorced in 1938. Jeremiah Jr. attended a parochial high school, McGill Institute, excelling in athletics and graduating in 1942. He studied at Spring Hill College in Mobile, but in 1943 entered the United States Naval Academy at Annapolis, Md., and graduated with honors in engineering in 1946.

In 1946, he married the former Kathryn Jane Maury. The couple had seven children. Mrs. Denton died in 2007.

Besides his son Jeremiah, Mr. Denton is survived by his second wife, Mary Belle Bordone; four sons, William, Donald, James and Michael; two daughters, Madeleine Doak and Mary Beth Hutton; a brother, Leo; 14 grandchildren and six great-grandchildren.

He served aboard the aircraft carrier Valley Forge in 1946 and 1947, testing and flying blimps. He also took flight training and became a pilot in the late 1940s, and over the next decade served as a flight instructor, test pilot and squadron leader. He studied at the Armed Forces Staff College and the Naval War College, becoming an expert on airborne electronics and antisubmarine warfare, and in 1964 earned a master’s degree in international affairs from George Washington University.

A year later, Commander Denton began flying missions over Vietnam.

Correction:March 28, 2014

An earlier version of this obituary misspelled the surname of one of Mr. Denton’s daughters. She is Madeleine Doak, not Doat. It also misidentified the Latin American country in which the Contra rebels operated. It was Nicaragua, not El Salvador.

A version of this article appears in print on , Section D, Page 8 of the New York edition with the headline: Jeremiah A. Denton Jr., 89, Dies; With Blinks, Vietnam P.O.W. Told of Torture. Order Reprints | Today’s Paper | Subscribe