Shigella flexneri 4a caused sustained outbreaks in a large long-stay psychiatric centre, Taiwan, 2001–2006. Trimethoprim-sulphamethoxazole (SXT) prophylaxis was administered in 2004. We recovered 108 S. flexneri 4a isolates from 83 symptomatic (including one caregiver) and 12 asymptomatic subjects (11 contacts, one caregiver). The isolates were classified into eight antibiogram types and 15 genotypes (six clusters) by using antimicrobial susceptibility testing and pulsed-field gel electrophoresis of NotI-digested DNA, respectively. These characteristics altered significantly after SXT prophylaxis (P < 0·05), with concomitant emergence of SXT-resistant isolates in two antibiogram types. P01 (n = 71), the predominant epidemic genotype, caused infection in two caregivers and five patients under their care; two P01 isolates were recovered from the same patient 6 months apart. These results indicate the importance of sustained person-to-person transmission of S. flexneri 4a by long-term convalescent, asymptomatic or caregiver carriers, and support the emergence of SXT-resistant strains following selective pressure by SXT prophylaxis.