Jennifer Aniston was almost replaced in 'Friends.'

The actress played Rachel Green in the much-loved comedy sitcom between 1994 and 2004, but was almost fired before it aired due to filming commitments with the short-lived series 'Muddling Through.'

"Friends came when I was off doing Muddling Through," Aniston recently revealed.

"So there was a period where I had to stand out of the photographs for the group shots, and I had phone calls from girlfriends saying, 'I'm auditioning for your part in Friends.' "

However, she felt thankful when the CBS sitcom flopped as it meant she was able to keep her part in 'Friends,' in which she starred along with Lisa Kudrow, Courteney Cox, David Schwimmer, Matthew Perry and Matt LeBlanc.

She continued: "They just took the chance that 'Muddling Through' would fail after the two episodes they picked it up for.

"So I just started doing this back-and-forth from Sony to Warner Bros. for two weeks."

Luckily for the 45-year-old actress, 'Muddling Through' only lasted three months so she was able to keep the role of Rachel.

She also confessed producers almost made her play Cox's character, Monica.

Speaking at the Santa Barbara International Film Festival, she said: "They wanted Courteney to play Rachel ... And unbeknownst to each other, I wanted to play Rachel and she wanted to play Monica.

"It worked out perfectly."