Few things confirm that a TV show is making an impact quite like when a bona fide star shows up for a guest appearance. So when Friends got not one but two mega-stars in actor-comedians Robin Williams and Billy Crystal, it was quite the eye-opener.

The two comedy legends appear before the opening credits in season three, episode 24 of the show, The One with the Ultimate Fighting Champion. Remarkably, Williams and Crystal’s Friends cameo, which came about because the two longtime comedy pals dropped by from a neighbouring set, was completely improvised on the day.

Robin Williams and Billy Crystal had a friendship dating back to the 1970s, when both were jobbing stand-up comedians. Williams got his big break in TV with hugely popular Happy Days spin-off Mork and Mindy, whilst Crystal rose to prominence with Soap, a less popular but well-reviewed comedy series.

The 80s and 90s saw both comedians rise to prominence in the movies: Williams appeared in such hits as Good Morning, Vietnam, Dead Poets Society and Mrs. Doubtfire, while Crystal headlined Throw Momma from the Train, When Harry Met Sally and City Slickers.

Credit: HBO via Getty

During this time, the only collaborations between Williams and Crystal were on the annual Comic Relief charity telethons, which they co-hosted alongside another of their close friends in comedy, Whoopi Goldberg.

However, Williams and Crystal didn’t co-star in a movie together until 1997, when they teamed up with director Ivan Reitman on the romantic comedy Father’s Day.

It was during production on Father’s Day that Williams and Crystal were intrigued to discover that they were shooting on a Warner Bros studio set right next to that of the most popular sitcom of the time, Friends.

Launched in September 1994, Friends enjoyed a meteoric rise. Such was the show’s success, celebrity guest appearances were commonplace even early on.

Season one featured guest spots from ER’s George Clooney and Noah Wyle plus Mad About You’s Helen Hunt, whilst season two boasted movie stars Julia Roberts, Brooke Shields, Charlie Sheen and Jean-Claude Van Damme.

When work began on season three’s The One with the Ultimate Fighting Champion, the biggest guest actor involved was Swingers star and future Iron Man director Jon Favreau, playing the fighter of the title. This changed when, much to the surprise of everyone, Robin Williams and Billy Crystal suddenly showed up on the set to introduce themselves.

The Friends cast and crew couldn’t believe their luck, and on the spot a plan was hatched to get the two comedy stars to shoot a cameo then and there – and, seemingly with no contracts or agents involved, Williams and Crystal agreed.

An all-new opening pre-titles scene for the episode was rapidly conceived and shot. It all starts out normal enough, with Ross, Rachel, Chandler, Phoebe and Joey hanging out at Central Perk when Monica arrives with a story to tell.

But no sooner has Monica started her story when two strangers, played by Williams and Crystal, suddenly appear, and ask if they too can sit down on the couch. The two men, credited as Tomas (Williams, putting on a characteristically bizarre accent) and Tim (Crystal), proceed to loudly start a conversation of their own, centred around Tomas’ fear that his wife is cheating on him.

As the conversation continues (and Monica is unable to continue with her own story), Tim reveals that he’s the man Tomas’ wife has been cheating with – after which the two men dramatically exit. At the scene’s climax, Monica admits she’s completely forgotten what she was going to tell her friends.

By all accounts, this sequence was almost entirely improvised, utilising Williams and Crystal’s renowned skills for comedic ad-libbing, and even allowing the regular cast members to do some improvising of their own.

This helped pave the way for even more big name stars to pop up in Friends in the years that followed, including Brad Pitt, Bruce Willis, Winona Ryder, Danny DeVito, Kathleen Turner and even Duchess of York Sarah Ferguson.

Credit: NBC

Friends actress Lisa Kudrow would also go on to work at greater length with Billy Crystal in the movie Analyse This and its sequel Analyse That.

Williams, meanwhile, went on to make the likes of Good Will Hunting and Flubber, before he tragically took his own life in 2014 following a period of mental illness. Crystal would remember his lost friend as “the boldest comedian I ever met – the boldest artist I ever met,” and later remarked, “it was a privilege to trade blows with him.”

As for the movie Williams and Crystal were making back in 1997, Father’s Day: that turned out to be a critically derided box office flop. But hey, we’ll always have their unforgettable Friends cameo.