Severe acute respiratory syndrome (SARS) has been transmitted extensively within hospitals, and healthcare workers (HCWs) have comprised a large proportion of SARS cases worldwide. We present a stochastic model of a SARS outbreak in a community and its hospital. For a range of basic reproductive numbers (R(0)) corresponding to conditions in different cities (but with emphasis on R(0) approximately 3 as reported for Hong Kong and Singapore), we evaluate contact precautions and case management (quarantine and isolation) as containment measures. Hospital-based contact precautions emerge as the most potent measures, with hospital-wide measures being particularly important if screening of HCWs is inadequate. For R(0) = 3, case isolation alone can control a SARS outbreak only if isolation reduces transmission by at least a factor of four and the mean symptom-onset-to-isolation time is less than 3 days. Delays of a few days in contact tracing and case identification severely degrade the utility of quarantine and isolation, particularly in high-transmission settings. Still more detrimental are delays between the onset of an outbreak and the implementation of control measures; for given control scenarios, our model identifies windows of opportunity beyond which the efficacy of containment efforts is reduced greatly. By considering pathways of transmission in our system, we show that if hospital-based transmission is not halted, measures that reduce community-HCW contact are vital to preventing a widespread epidemic. The implications of our results for future emerging pathogens are discussed.