Live television is a high-wire act in the best of times. But on a Grammy telecast, with its mercurial slate of divas and rock stars, even the best-laid plans often go awry.

When that happens, and the show threatens to go off the rails, it’s up to producer Ken Ehrlich to improvise and avert disaster — whether it’s the day before, or the show is already under way.

In 2009, production toppers received word the morning of the show, during dress rehearsal, that Rihanna would not be performing as scheduled. A few acts later in the show order, Chris Brown missed his rehearsal slot. They later learned he was preparing to turn himself in to the police ahead of felony criminal threat charges. With three hours to air, Ehrlich had a 10-minute hole in the show.

“You can’t panic in a situation like that, because once you do, you’ve lost your way,” says National Academy of Recording Arts and Sciences president Neil Portnow.

Ehrlich coolly approached Justin Timberlake to save the day.

“That’s a hard ask,” CBS executive VP of specials, music and live events Jack Sussman observes. “Justin said, ‘I’m in, but what are we going to do?’ ” Timberlake looked over a list of who was to be in the theater that night and picked Al Green for a duet. Green was in the shower when the call came.

“Me and Justin performed ‘Let’s Stay Together,’ and we saved the world!” Green told CBS later.

Ehrlich has even had to improvise during the show. At the top of the 1998 telecast, with a 40-piece orchestra and 20 backup singers ready to go on, opera legend Luciano Pavarotti called in sick.

“He came up to my dressing room and said, ‘We need you to sing,’ ” says Aretha Franklin, who was already scheduled to perform with the Blues Brothers that night. “I said, ‘What? Oh my God.’ ”

He asked her to go on in just a few minutes and cover “Nessun Dorma,” a song she’d recently performed at another event—but in a different key, since it was too late for the band to change their arrangement. Fortunately, Franklin had the range to pull it off.

“I had a great time. I loved the entire production,” she says.

Sometimes a crisis is an emotional one. The day before the 2012 Grammys, Whitney Houston was found dead. The loss cast a pall over the pre-Grammy party for the performers, which was solemn and unsettled, and the mood threatened to dampen the show.

LL Cool J, who was to host the show, called Ehrlich from the party to ask if he could lead a prayer for Houston.

“He was courageous enough to allow me to do that,” LL Cool J says. “It turned out to settle the wound, if nothing else, and give people a chance to exhale, so those artists and everybody who wanted to celebrate felt like they were granted permission to now move on and have a good time.”

Then there was the matter of how to acknowledge Houston’s passing on the show. A downtrodden tribute is not what Houston would have wanted, LL Cool J told Ehrlich. For his part, Ehrlich says “I don’t want to do tributes. It’s too fresh.” Instead, Ehrlich arranged for Jennifer Hudson to sing Houston’s hit “I Will Always Love You.”

“He quarterbacked that thing like you wouldn’t believe,” says LL Cool J. “The performances changed. People changed. There were mood swings. There were all kinds of ebbs and flows in the process that really changed the dynamics. I think he handled it superbly.”

Jon Weisman contributed to this report.