The ending to How I Met Your Mother was a controversial one, however, there is no denying that the sitcom had some memorable moments and episodes. "Slapsgivving" will forever be regarded among the show's elite concepts - for nine seasons we saw some great storylines play out.

RELATED - Britney Spears' Former Restaurant Nyla Went $350,000 Over Budget On Opening Day

However, like other sitcoms, How I met Your Mother was facing pressure from the network, given its ratings decline. It was Britney Spears' team that contact the show and in turn, the pop star icon might have saved the sitcom with her low-key role.

Let's take a look at how it all went down.

It Was Britney Spears' Team That Got In Contact With How I Met Your Mother

At the time of her appearance on the show, Britney's team thought it was time for a refresh. They wanted the star to work on something lighter. It caught How I Met Your Mother's team completely off-guard when they reached out, expressing interest about getting her on the show.

Executive Producer Chris Harris recalled the moment, one nobody could have predicted. “As far as I remember, Britney Spears appeared from nowhere. Her team thought she needed a reset, to be re-presented in public, and they wanted something nice and fun."

RELATED - The Truth Behind Elton John And Britney Spears' Collaboration

A major character was first pitched to Spears as Stella, however, the pop star wanted a smaller role. She eventually accepted the role of a receptionist, one that co-creator Carter Bays praised Spears for alongside Mirror. "Britney instead wanted to play the smaller role, this character Abby who had maybe two scenes."

"We were kind of surprised by this choice. But she came in and she really shone in those scenes and we brought her back for another episode."

Turns out, not only was the cameo huge for the show, but it might have also saved the show in general.

Britney Spears' Cameo Spiked How I Met Your Mother's Ratings At A Time They Needed It Most

Looking back, the show's creators revealed that the timing of Britney's interest in the show could not have been any better. How I Met Your Mother was still performing solidly with its hardcore fans, however, ratings were not increasing either. The show needed a big spark and got exactly that. Carter Bays had a lot of praise for what Britney did for the show, in such a small role.

"It brought a lot of eyes to the show. We were doing okay in the ratings but we weren’t really exploding, and [Britney] brought a ton of new eyes to it."

"I’m very thankful that happened to be an episode I was really proud of and that had a lot of funny stuff in it. It was a big turning point in the show, our audience grew sizeably that day."

RELATED - How Neil Patrick Harris Really Felt About Playing A Straight Character On How I Met Your Mother

Not only that but there was a major buzz outside the studio as well, with helicopters circulating the building in anticipation of Britney's appearance. It was quite the moment and one that saved the show for some extra seasons. The 2000s sitcom enjoyed nine seasons and 208 episodes.

Not Every Cast Member Was Eager About Britney Spears' Appearance

Neil Patrick Harris wasn't as eager... to be fair, he wasn't singling Britney Spears out, the actor just wasn't a fan of cameos in general. According to NPH, too many guest-stars have hurt other sitcoms in the past and he didn't want the same thing to go down on How I Met Your Mother.

The actor said, "I’m in the minority that our show does not need stunt casting in order to succeed. I worry that if they start ‘Will and Grace'-ing us too much, that the show will suffer. And we’re all really proud of the content of the show. I mean, viewership is not our game. It’s the network and the studio’s game, you know. It’s the promotion department’s game."

We can understand where the man behind Barney Stinson is coming from. Nonetheless, Spears' appearance on the show was vital, giving the sitcom the desperate boost it very much needed at the time.