EXCLUSIVE

Yolanda Foster ﻿didn't want to be treated like a second class citizen on 'Real Housewives of Beverly Hills' -- and decided to leave the show rather than be demoted from the main cast ... TMZ has learned.

Foster announced she was leaving the show in an Instagram statement -- and implied that she was fired.

But our production sources say that's not exactly the case ... telling us Yolanda was offered a role as a "friend of the cast" -- which would give her more free time to address her health issues.

We're told Yolanda saw the move as a demotion -- since she was a full-fledged cast member in the past few seasons -- and refused to take a lesser role.