Patients in some randomized clinical trials may start additional non-randomized medication because of an exacerbation of symptoms or insufficient therapeutic effect. Typically this rescue medication reduces the observed treatment effect in intention-to-treat analysis. We discuss methods of analysis which take account of rescue medication in order to achieve a more meaningful comparison of the randomized treatments, focusing on trials with a repeated quantitative outcome. Ignoring all data after rescue is likely to be biased because rescued patients are a highly selected group. Instead we propose using methods based on ranks or multilevel models. The rank-based methods assume that rescued patients have especially bad underlying outcomes. The multilevel regression model relates a patient's outcome to allocated treatment and rescue status at each time, and requires correct modelling of all prognostic factors which predict starting rescue medication and of the covariance between outcomes measured at different times. We also describe sensitivity analyses over a range of possible models for the effect of rescue medication. We illustrate these methods in a trial in Parkinson's disease. It appears that adjustment for rescue medication will not radically alter the randomized treatment comparison unless rescue medication is substantially imbalanced between randomized groups and has a substantial effect on the outcome.