Bruzzi et al. (1985, American Journal of Epidemiology 122, 904-914) provided a general logistic-model-based estimator of the attributable fraction for case-control data, and Benichou and Gail (1990, Biometrics 46, 991-1003) gave an implicit-delta-method variance formula for this estimator. The Bruzzi et al. estimator is not, however, the maximum likelihood estimator (MLE) based on the model, as it uses the model only to construct the relative risk estimates, and not the covariate-distribution estimate. We here provide maximum likelihood estimators for the attributable fraction in cohort and case-control studies, and their asymptotic variances. The case-control estimator generalizes the estimator of Drescher and Schill (1991, Biometrics 47, 1247-1256). We also present a limited simulation study which confirms earlier work that better small-sample performance is obtained when the confidence interval is centered on the log-transformed point estimator rather than the original point estimator.