A black-clad man with a rifle stashed under his coat gunned down two people in a Texas church Sunday before being slain by parishioners in a caught-on-tape shootout.

The bloodshed erupted in the middle of services at the West Freeway Church of Christ in White Settlement, a suburb of Fort Worth, around 10:50 a.m., authorities said.

Stunning footage of the service — which was being livestreamed by the Christian church on YouTube — shows the killer in a large coat, black hat and apparently a long, bushy black beard enter the church from the rear and shake the hand of a woman before sitting alone in a pew along the left side.

He soon gets up and approaches a man standing by the wall.

As the unsuspecting congregation, including many older couples, concentrate on their prayer books, the gunman appears to ask the man a question.

The man responds by pointing to his right, where another guy is sitting along the wall.

The man who was sitting gets up and appears to be pulling something out from the back of his waistband when the killer opens fire, shooting him and causing him to fall to the ground.

The killer then shoots the guy of whom he’d asked the question, before being gunned down by two parishioners — including a former FBI agent working security, according to officials and CBS TV affiliate KVTV.

Meanwhile, several other male worshipers whip out their own firearms and move toward the shooter as he remains down. The state recently passed a law allowing licensed gun owners to carry weapons in church.

As the bullets flew, stunned congregants cried and screamed while ducking for cover under pews. The man who had been in front of the church on the low stage started crawling down the aisle on his hands and knees.

“I love you!” one congregant shouted, according to ABC TV affiliate WFAA.

The killer and one of his victims died en route to the hospital, while the other person who was shot died at the hospital Sunday, CNN reported.

One victim worked security at the church, a West Freeway elder told the New York Times.

“He was trying to do what he needed to do to protect the rest of us,” said the elder, Mike Tinius.

Two other people were treated for minor head injuries they sustained while ducking for cover, a medical official told the Dallas Morning News.

Authorities hailed the duo who brought down the killer as “heroic.

“Today, evil walked boldly among us. But let me remind you, good people raised up and stopped it before it got worse,’’ Sheriff Bill Waybourn of Tarrant County, where the shooting occurred, told reporters at a press conference.

An FBI spokesman said his agency is still investigating.

“We are working very hard to find motive, to get to the bottom of what happened,’’ said Matthew DeSarno, special agent in charge of the FBI’s Dallas field office.

Authorities said there is no continuing threat to the church.

The shooting came just over two years after the massacre at the First Baptist Church in Sutherland Springs, Texas, in which 26 people died and 20 more were wounded.

Sutherland mass murderer Devin Kelly, who committed suicide before he could be apprehended, had been feuding with his mother-in-law, who attended the church.

Texas Department of Public Safety Regional Director Jeoff Williams told reporters after the latest church shooting, “Unfortunately, this country has seen so many of these that we’ve actually gotten used to it at this point.’’