In the US, there are laws specifically protecting people from being fired from jobs for certain reasons.
These almost universally include race, sex, sexual orientation, age, disability, becoming pregnant, being required to participate in a mandatory action like jury duty, and I think being recalled to the military if you are on inactive status.
If an employer violates these, the ex-employee has grounds to sue.