There is a notion in the law that employees can be terminated "at will" or at the whim of the employer.
This is actually untrue.
An employee can be fired for any legal reason (even an arbitrary legal reason).
HOWEVER, an employee cannot legally be fired, or demoted, or suffer certain adverse employment consequences when the employer's conduct is illegal or violates an express or implied employment contract.
When an employee is fired for an illegal reason, he or she can bring a claim for wrongful termination. When an employee is fired in violation of an employment contract, he or she can bring a claim for breach of contract.