As the opening credits roll in the new PBS documentary series from Henry Louis Gates Jr., The Black Church: This is Our Story, This is Our Song, a familiar Island scene appears: Union Chapel in Oak Bluffs on a summer Sunday, with latecomers clustering around the doors of the sanctuary.

Among the overflowing congregation inside, the camera spots Mr. Gates in a front pew, listening intently to guest preacher Rev. Otis Moss 3rd. It’s a fitting start for the new series, which Mr. Gates said was inspired by an earlier summer service at the historic church.

“I essentially got the idea from Union Chapel,” Mr. Gates told the Gazette this week by phone from his home in Cambridge.

“I wanted to try to recreate that feeling of being wrapped in a warm blanket on a frigid day,” he said. “That’s how I feel leaving Union Chapel, (where) working class, middle class, upper class . . . doesn’t matter. It’s a cultural event, as well as a religious event.”

Rev. Otis Moss 3rd (seated) preaching at Union Chapel appears in the film. — Jeanna Shepard

Similarly, Mr. Gates said, the black church has always done more than simply tend to the spiritual needs of its parishioners, from the earliest days when enslaved people’s African religious traditions began filtering into the dominant Christianity.

“It was a sanctuary — not just a religious sanctuary, but a sanctuary from the abuses of racism,” he said. “You could be treated badly six days a week by white racism, but on the seventh day you could walk into the church and you were a king or a queen. You had as much dignity as anybody anywhere.”

Through interviews, new and archival footage and vintage photographs, the four-hour series traces the formation of black worship in America, the development of the black church as a social and political powerhouse and the challenges it continues to face in an increasingly secular society. Mr. Gates has also written an accompanying book by the same name, published in February.

Though racism forced black people into separate congregations for hundreds of years, the series argues it was those very churches that took the lead in fighting segregation after the Civil War and especially in the second half of the 20th century.

“Without the black church, there wouldn’t be a civil rights movement,” Mr. Gates said.

Music also plays an important part in telling the story. The series is packed with gospel, and Mr. Gates himself breaks into song several times. Even the subtitle of the series comes from a hymn, Blessed Assurance.

Shooting footage at Union Chapel. — Jeanna Shepard

“I was raised in the church, and I have all these songs in my head,” Mr. Gates told the Gazette.

In one of the documentary’s most moving sequences, he leads the congregation at his childhood church in West Virginia, singing The Prodigal Son as he pounds rhythm on the side of the lectern: “I believe, I believe I will go back home and be a servant of the Lord.”

Mahalia Jackson, Aretha Franklin and the Hawkins Family also appear — so do San Francisco disco legend Sylvester and the rap group N.W.A. — in sections dealing with church responses to the AIDS crisis and hip-hop music.

Mr. Gates also delves into the “preaching on wax” phenomenon that arose in the early days of the recording industry, when sermons like I’m Going to Die with the Staff in My Hand, recorded by Rev. J.M. Gates around 1925, could sell 50,000 copies.

“He sold almost two times more records for Columbia than Bessie Smith,” Mr. Gates said.

Another best-selling preacher was Rev. C.L. Franklin, Aretha’s father, whose 1953 sermon The Eagle Stirreth Her Nest is listed in the National Recording Registry of the Library of Congress.

Making The Black Church took Mr. Gates to sanctuaries across the country, from Oak Bluffs to Los Angeles and from Savannah, Ga. north to Chicago.

“I loved it,” he said.

Houses of worship featured in the series range from small and simple churches, like Bishop Yvette Flunder’s City of Refuge United Church of Christ in Oakland, Calif., to Bishop T.D. Jakes’s Dallas megachurch The Potter’s House, which holds 14,000 worshipers and has a 400-acre campus.

But Mr. Gates has an unflinching eye. Viewers also see churches in flames and reduced to rubble from arson and bombings, and hear the gut-wrenching emergency call from Mother Emanuel African Methodist Episcopal Church in Charleston, S.C., after a young white supremacist shot and killed the pastor and eight parishioners in 2015 — more proof that racism remains a mortal threat.

His latest in a string of acclaimed documentaries and companion books on the black American experience, The Black Church has proved to be the most popular as well.

“I’ve never had more response to anything I’ve ever done,” Mr. Gates said.

The Black Church: This is Our Story, This is Our Song can be viewed online or obtained on DVD from libraries and online retailers. Mr. Gates’s book is also available from bookstores, other retailers and libraries.