LOS ANGELES — The ongoing popularity of the infamous Madea character surprises even the man who plays her. Asked if he thought when first donning the wig and old-lady wardrobe 18 years ago that he’d still be doing the role in 2016, Tyler Perry had an immediate response.

“God no! I just thought this was a flash in the pan, and it would be one or two performances — and then it would be done. But the audiences won’t let her go.”

Perry’s latest Madea film, “Tyler Perry’s Boo! A Madea Halloween,” opens Friday.

As Perry sees it, Madea’s fans “are reminded of a grandmother from back in the day — one who was there and authentic and wasn’t politically correct, and said what was on her mind, and who looked out for the whole family, and set things straight.”

While Perry has created nearly a dozen “Madea” films, Halloween was never a theme he thought would be a natural for his iconic character.

“It was Chris Rock who did ‘Boo! Madea Halloween’ [a fictitious film in Rock’s 2014 film ‘Top Five’], which I thought was so ridiculous. But when Lionsgate saw it, they said, ‘You’ve got to do that movie!’ ”

Even so, Perry still was hesitant. “I’m not a witches or goblins kind of guy — so I needed something that worked for me. Then, this concept came to mind, literally while I was watching a bunch of YouTube videos of people being pranked,” said Perry, explaining how he came up with the basic plot points for “Boo!” In the movie, Madea spends a crazy Halloween fending off killers, paranormal poltergeists, ghosts, zombies and those goblins Perry doesn’t like — all while keeping watch over a group of rambunctious teenagers.

“I just wanted to avoid a paranormal activity in its purest form. I just couldn’t do that. That’s why the prank approach worked for me.”

While Perry actually plays three separate characters in this latest film, he explained he never lets them get to him.

“When I take the costume off, they’re gone. I get them out of my head. They don’t stick around. I’ve been doing them for so long, it’s not hard for me. ‘You just pop into it!’ ” Perry said, immediately slipping into Madea’s voice.

Will this be the swan song for Madea? “I have no idea, because I didn’t envision her doing a Halloween film,” said Perry, who did note that improvisation often comes into play when Madea is at work.

“Things simply come up. You write it on paper when you’re doing the script and you think it’s funny. But when you’re actually filming it, and you see the other characters, it becomes funnier — especially if you just relax and go with the flow of the moment.”