Cardi B is getting sued for allegedly assaulting, striking and spitting on a female security guard, but witnesses saw it differently and feel Cardi was the one wronged.

The woman, named Emani Ellis, filed the lawsuit against Cardi Friday in Los Angeles County Superior Court. According to the suit, Ellis was at work in Bev Hills on Feb. 24, 2018, when the encounter with Cardi happened.

In the docs, obtained by TMZ, Ellis alleges Cardi maliciously struck her in the head, face and body. Ellis, who says she's African-American, also claims Cardi spit on her and used profanities and racial slurs.

This all went down in a medical building, and eyewitnesses tell us Cardi had just left an appointment -- and the security guard approached Cardi trying to record video or take photos of her. We're told Cardi asked her to stop because she didn't want to be recorded in the doctor's office.

It's also worth noting ... Cardi had not revealed her pregnancy yet. The date of the incident indicates she would've been about 4 months pregnant with Kulture.

The witnesses tell us the security guard got upset and she and Cardi -- who didn't have security with her at the time -- did get into argument. We're told a building staffer ran out and got in between the guard and Cardi, and things never got physical, and there were no racial slurs.

According to the lawsuit, Cardi "then used her celebrity status to get [Ellis] fired from her job as a security guard." However, a rep for the medical building tells TMZ, Cardi's doctor and patient coordinator were the ones who got the guard fired because they both felt the guard had violated Cardi's privacy. The rep says Cardi gave them permission to release that information.