Brendan Gleeson wasn’t certain about starring in ‘Mr. Mercedes’

All that was holding him back was the part of the story about how the people were killed.

LOS ANGELES — The chance to star in the new AT&T Audience Network series, “Mr. Mercedes,” was a great opportunity for Brendan Gleeson. Although the Irish actor has been working professionally for almost three decades, he’s best known for playing Alastor “Mad-Eye” Moody, a supporting character in the “Harry Potter” films.

The role of Bill Hodges in “Mr. Mercedes” — the series based on the book by Stephen King that launches 8 p.m. Wednesday on the streaming service — would give him the chance to play a retired police detective haunted by one of the last cases in his long career. He was never able to figure out the identity of a man who called himself Mr. Mercedes, a reference to the car he stole to drive through a crowd at a job fair, killing 16.

There’s a tight race going on as to whether the ex-detective’s excessive weight, endless drinking or the taunting by the killer will be the chief cause of his death. The only things keeping him going are a lustful neighbor (Holland Taylor) and a caring client (Mary-Louise Parker).

It’s a very deep and complicated role. All that was holding Gleeson back was the part of the story about how the people were killed. The actor feared that by showing the incident on screen, it might give someone an idea to commit a real-life version of the story King wrote.

It wasn’t until he got to talk to King that he felt a bit of relief about taking on the role. Gleeson says King told him he the idea for the sequence in the book was based on a real incident where someone had driven into a line of people.

“So it has been taken from life into art. And I was uneasy about the notion of putting this out there as I said, ‘Well, anybody can get into a car.’ But actually, it already has existed and has been out there,” Gleeson says. “All of this has been happening.”

The King discussion was comforting, but it was a talk Gleeson had with Jack Bender — an executive producer of the short series, along with David E. Kelly — that convinced him it would be OK to take on the role. Bender was certain from the start that Gleeson was the perfect person to play the burned-out detective, and King fully agreed.

“Mr. Mercedes” starts with the horrific act but quickly shifts to looking at a group of emotionally damaged people brought together around this incident. During their conversation, Bender assured Gleeson that any violence in the production would not be done for titillation.

“This darkness is there, if we want to embrace it. This terror is there. The horror is there, if you want to embrace it. Hodges is very tempted to embrace it and to go into that dark place. Mary-Louise’s character is one of the people who is hugely instrumental in taking him out and breathing hope and all of that positivity,” Gleeson says.

Everything is set in motion by Brady Hartsfield (Harry Treadaway), a demented killer who splits his time between taunting the retired detective with letters and messages through his computer and working as both a computer technician and operator of an ice cream truck. Both jobs give him access to the people he targets. The work also gets him away from home where his lives with his mother (Kelly Lynch). who shows an unnatural attraction for her son.

Treadaway, who portrayed Dr. Victor Frankenstein in “Penny Dreadful,” calls the character of Brady Hartsfield the creepiest character he had read in a long time.

Gleeson applauds the work Treadaway and the rest of the cast has done with the very emotional charged story.

If “Mr. Mercedes” gets enough viewers, the streaming services would adapt the other two books in the trilogy that King calls his first attempt at writing about a hardboiled detective.

The Audience Network can be seen through DirecTV, AT&T U-verse and DirecTV Now.