Rep. John H. Buchanan Jr. (R-Ala.). (Collection of the U.S. House of Representatives)

John H. Buchanan Jr., a third-generation Baptist minister from Alabama who served eight terms in the U.S. House of Representatives as a moderate Republican until being swept out of office by the religious right, then became an activist for the liberal lobbying group People for the American Way, died March 5 at an assisted-living center in Rockville, Md. He was 89.

The cause was complications from dementia, said a daughter, Liz Buchanan.

Mr. Buchanan was voted into office in 1964 along with four other Republicans as Alabama voters turned against the Democratic Party after President Lyndon B. Johnson signed the Civil Rights Act of 1964. He unseated 10-year Democratic incumbent George Huddleston Jr. — who was one of Mr. Buchanan’s parishioners — to represent Alabama’s 6th District, which included Birmingham, a city notorious for its civil rights clashes.

At first, Mr. Buchanan had a conventional conservative record and voted against the Voting Rights Act of 1965, but his experience at the biracial Riverside Baptist Church in Southwest Washington led to a shift in his views.

“When you’re deeply involved in a biracial entity, you think of people as brothers and sisters,” he told The Washington Post in 1976. “Then the denial of rights of my brothers and sisters becomes an infringement of my rights as well.”

Mr. Buchanan eventually broke with Republicans on civil rights issues but stayed in line when it came to foreign policy, taking a hard-line position in support of U.S. involvement in the Vietnam War.

Over time, as other Southern Republicans drifted further to the right, Mr. Buchanan began to adopt more moderate positions, including supporting Title IX of the 1972 Education Act, the landmark anti-discrimination law that required equality for women in college and university programs, including sports.

He also called for full voting rights for residents of the District of Columbia, including representation in the House and Senate. On the Foreign Affairs Committee, he advocated for Jewish and Christian dissidents behind the Iron Curtain.

“John straddled issues,” Wayne Flynt, a historian at Alabama’s Auburn University, said in an interview. “He was a centrist in an age where centrism was beginning to be challenged and would finally result in the polarization of American politics into left and right. ”

Although Mr. Buchanan once supported a constitutional amendment allowing school prayer, he was targeted for defeat in 1980 by Moral Majority, a powerful conservative movement led by televangelist Jerry Falwell.

“John Buchanan may have voted for it somewhere,” the New York Times quoted an Alabama Moral Majority official as saying, “but basically he was against it.”

After losing in the primary to Albert Lee Smith, a former member of the John Birch Society, Mr. Buchanan later devoted his career to countering Moral Majority. In the early 1980s, he became the founding chairman of the People for the American Way, founded by television producer Norman Lear.

“It couldn’t have been more exciting to have a Republican officeholder, a former officeholder from Alabama,” Lear said in an interview with The Post. “He was extremely helpful in making it nonpartisan.”

John Hall Buchanan Jr. was born in Paris, Tenn., on March 19, 1928, and grew up in Birmingham, Ala. Both his grandfather and father were Baptist ministers, and his mother was a homemaker.

Mr. Buchanan served in the Navy in 1945 and 1946 as a hospital corpsman, graduated from Samford University in Birmingham in 1949 and received a master of divinity degree from the Southern Theological Seminary in Louisville in 1957.

He was a pastor in Tennessee, Virginia and Alabama before making an unsuccessful run for Congress in 1962. After settling in Washington, he was twice the interim pastor of Riverside Baptist Church in the District.

Mr. Buchanan spent about three decades on the board of People for the American Way and appeared on television as the group’s spokesman.

His wife of 50 years, the former Elizabeth “Betty” Moore, died in 2011. Survivors include two daughters, Liz Buchanan, of Arlington, Mass., and Lynn Buchanan of Rockville, Md.; and three granddaughters.

“I’ve become more emancipated as I’ve gone along,” Mr. Buchanan said in 1976, describing the evolution of his political views.

“I’m at the point in my political career where I’d rather lose . . . than fail to do what I think is right. I won’t compromise on civil rights any more. I can’t do it, I will not do it.”