Fantasia Barrino is under a self-imposed lockdown — after the “American Idol” champ received a threatening letter.

It all started last night at the Pantages Theater in L.A. — Fantasia was reading her fan mail after a performance of “The Color Purple.”

Fantasia’s manager tells us Barrino became alarmed over a disturbing letter loaded with racial slursincluding the n-word — and a line that read, “go back where you came from and die.”

We’re told the person who wrote the letter claims he used to work as a security guard for Fox while Fantasia was on “A.I.”

Fantasia’s manager tells us the singer immediately contacted theater security — which then contacted the LAPD.

In the meantime, we’re told the theater has “beefed up” security around Fantasia — and all over the venue — and will be screening anything sent to Barrino’s dressing room before it gets to her.

Fantasia tells TMZ, “I will not be defeated by one isolated person’s hatred.”