The backbone is Title VII of the Civil Rights Act of 1964, which bars employment discrimination based on race, color, religion, sex and national origin under 42 U.S.C. § 2000e-2. It applies to employers with 15 or more employees (42 U.S.C. § 2000e(b)). The Age Discrimination in Employment Act protects workers aged 40 and older at companies with 20 or more employees, the Americans with Disabilities Act covers disability at the 15-employee threshold, and the Genetic Information Nondiscrimination Act adds genetic information. Pregnancy is part of "sex" by statute (42 U.S.C. § 2000e(k)), and in Bostock v. Clayton County (2020) the Supreme Court held that firing someone for being gay or transgender is discrimination because of sex. Sexual harassment is defined in the EEOC guidelines at 29 C.F.R. § 1604.11 as unwelcome sexual advances, requests for sexual favors and other verbal or physical conduct of a sexual nature, when it affects employment decisions or creates an intimidating, hostile or offensive working environment.
Two Supreme Court decisions from 1998, Faragher v. City of Boca Raton and Burlington Industries v. Ellerth, explain why a written complaint carries so much weight. When a supervisor creates a hostile environment without a tangible job action, the employer can defend itself by showing that it took reasonable care to prevent and correct harassment, typically through a complaint procedure, and that the employee unreasonably failed to use it. A dated letter answers the second half of that defense.
Retaliation is a separate violation. 42 U.S.C. § 2000e-3(a) forbids punishing an employee "because he has opposed any practice" made unlawful by Title VII, and the EEOC treats a complaint to a manager or HR as protected opposition, even without legal vocabulary.
The internal complaint does not stop the federal clock. Under 42 U.S.C. § 2000e-5(e)(1), a charge must be filed within 180 days of the discriminatory act, or 300 days where a state or local agency has authority over the same practice, and the EEOC explains on its page on time limits for filing a charge of discrimination that an internal grievance does not extend that window. For harassment, the count starts from the last incident; for a single decision such as a firing, from the date of that decision.