It has been known for some time that human autoimmune diseases can be triggered by viral infections. Several possible mechanisms of interactions between a virus and immune system have been analysed, with a prevailing opinion being that the onset of autoimmunity can in many cases be attributed to "molecular mimicry", where linear peptide epitopes, processed from viral proteins, mimic normal host self-proteins, thus leading to a cross-reaction of immune response against virus with host cells. In this paper we present a mathematical model for the dynamics of an immune response to a viral infection and autoimmunity, which takes into account T cells with different activation thresholds. We show how the infection can be cleared by the immune system, as well as how it can lead to a chronic infection or recurrent infection with relapses and remissions. Numerical simulations of the model are performed to illustrate various dynamical regimes, as well as to analyse the potential impact of treatment of autoimmune disease in the chronic and recurrent states. The results provide good qualitative agreement with available data on immune responses to viral infections and progression of autoimmune diseases. (C) 2012 Elsevier Ltd. All rights reserved.