We present a method to estimate the time-dependent vaccine efficacy from the cohort-specific vaccination coverage and from data on the vaccination status of cases and apply it to a measles epidemic in Germany which involved 529 cases, 88 of whom were vaccinated and 370 unvaccinated (for the remaining 71 cases the vaccination status is unknown). Our epidemiological model takes into account that maternal antibodies prevent successful vaccination and that vaccine immunity may be lost over time. Model parameters are estimated from the data using maximum likelihood. Vaccination coverage, as determined in school surveys, ranged from 27.6 per cent for the cohort born in 1974 to 85 per cent for the 1986 cohort, which is far too low to prevent measles transmission. Cohorts for which no school surveys were performed are omitted from analysis. Thus, sufficient data are available for only 282 cases, 69 of whom are vaccinated. According to our estimates, measles vaccinations provided no immunity before 1978 (95 per cent CI: 0 to 47 percent), for the period 1978-1982, the estimated vaccine efficacy was 80 percent (95 percent CI: 67 to 89 percent), and for 1982-1990 it was 97 percent (95 percent CI: 93 to 99 percent). After 1990, the estimated value dropped to 89 per cent, but its confidence interval widely overlaps with that of the previous period (95 percent CI: 74 to 97 percent). Loss of immunity was estimated to be zero (95 percent CI: 0 to 0.003/year). Several sensitivity analyses were performed with respect to the model assumptions. A modified model which assumed constant efficacy at all vaccination times yielded a high estimate of 96 per cent (95 percent CI: 92 to 98 percent) for primary vaccine efficacy but also a high loss rate of immunity of 0.007/year (95 percent CI: 0.001 to 0.012) to explain the high fraction of vaccinated cases among older individuals. The likelihood score value is however significantly inferior compared to the score value of the model with time-dependent vaccine efficacy.