'IT Chapter Two': James McAvoy and Director Andy Muschietti Discuss THAT Cameo

And why his appearance might mean the movie would "bomb."

Warning: Spoilers below for "IT Chapter Two," now playing in theaters.

Stephen King has arrived in Derry.

In IT Chapter Two, Bill (James McAvoy) and the rest of the Losers are called back to their hometown to once again face the villainous Pennywise (Bill Skarsgård). But before they do, they each take a stroll down memory lane, which lands Bill in an antique shop opposite a very special cameo from none other than Stephen King himself, the author of the 1986 novel that provided the groundwork for both films.

"After Chapter One, he saw the movie and really enjoyed it and we started to have a very friendly relationship," director Andy Muschietti told ET's Ash Crossan about how the appearance from the King of Horror came together. "His first instinct was, 'Yeah, well you have to consider that I'm a jinx.'"

According to Muschietti, King was worried that whenever he appears in an adaptation of one of his stories, it typically "bombed" at the box office. And he isn't necessarily wrong: films and mini-series like Maximum Overdrive, Storm of the Century and The Langoliers all include King cameos and are lesser known outside. the author's most devoted fans.

"And I said, 'It doesn't matter, Stephen. I think we can fight this,'" Muschietti shared.

Once King agreed to participate, the trick became finding the right moment for him to appear. The shopkeeper at the Secondhand Rose presented just the right opportunity.

"He wrote this character in the book of a curmudgeonly old Mainer from Bangor -- or from Derry, in the book -- and he's one of those guys who, you know, when you go to your hometown, whether you've made it big or not, people feel the need to bring you back down to Earth and put you in your place," McAvoy explained."There's no better person to play it than him... You just need one scene and you know exactly who that character is and he does it so brilliantly."

In King's novel, the scene in Secondhand Rose, Secondhand Clothes is more suspenseful, with the shopkeeper palming a gun hidden behind the counter when Bill enters. Onscreen, the end result is a sequence in which King, a real author, manages to put Bill, a fictional author, in his place -- while also winking at the audience.

"There was improvisation in the scene," Muschietti recalled. "McAvoy came with an idea and there was a lot of spit-balling there that made the scene that you see more fun. It ended up being like a comedy scene, almost. It was very exciting. You see how people react when they see him, like they go crazy."

McAvoy remembers that, when the day came to shoot the scene, a number of King's "brilliant, derogatory one-liner zingers" had mysteriously been cut from the script, which left the actor fighting "to get Stephen King's written words back into Stephen King's mouth."

"I felt like I was his agent or something, like fighting for his right to respect the source material," McAvoy joked. "It was hilarious. I don't know why, it was some weird mistake in printing that half the scenes disappeared, but we fought for it and it all got back in."

While King's appearance is the most obvious nod to fans in the scene, Muschietti says there are a number of other sublt references worked in. A native Argentinean, the director had the author drinking mate, a popular Argentinean infusion, in the scene. "We drink it a lot in South America," he said. "And [the cup] has the logo of my football club, my football team, as a little Easter egg."

"There's [also] something behind Stephen King in that scene that Stephen King fans will recognize," Muschietti plays coy. "I don't want to tell you what it is. You should find it yourself. That's how Easter eggs work."