Tom Arnold’s appearance at ex-wife Roseanne Barr’s Comedy Central roast was the hit of Sunday’s broadcast — but, behind the scenes, Arnold refused to play ball until specific demands were met, sources tell Page Six.

Arnold wanted a guarantee Barr wouldn’t bad-mouth him and would even say “something nice” in exchange for his appearance, sources said.

“Comedy Central first approached Tom and wanted him to come onstage dressed as a waiter, and serve Roseanne a drink, then leave,” said a source. “He said, ‘That’s not gonna happen.’ ” The network then came up with a series of other ideas that Arnold also shot down. But when execs said he could have free rein, Arnold agreed — under one condition.

“Tom wanted assurance that Roseanne wasn’t going to bad-mouth him,” our source said. “[His team] went so far as to insist she say something nice about him . . . [in return] for him doing the appearance.”

Roseanne even called Tom, to assure him it wasn’t a trap. “She told him maybe we can bury the hatchet,” a source said.

The pair hadn’t spoken since Arnold starred in hit “True Lies” in 1994. He’s currently gaining buzz for Dax Shepard’s upcoming summer comedy, “Hit and Run” co-starring Kristen Bell.

At Sunday’s roast, which included guests Carrie Fisher, Ellen Barkin and Jane Lynch, Arnold ribbed Barr, saying, “She may not be the perfect wife, but she’s literally the worst ex-wife on the planet.” But he also gave a tribute, adding, “Roseanne, you were my Johnny Carson . . . thank you for the thumbs-up and thank you for inviting me to sit on your couch for a little bit.”

Barr did manage to say something nice, then ripped Arnold, saying, “I’d really like to thank Tom for showing up tonight . . . he was very funny . . . but, Jesus Christ, how many [bleeping] jobs do I have to get for that guy?” She summed up, “If I can bury my roiling, boiling ceaseless hatred for the likes of Tom Arnold, maybe there’s a chance we can have world peace.”

Reps for Arnold and Barr did not return requests for comment.