A two-step generalized method of moments estimation procedure can be made robust to heteroskedasticity and autocorrelation in the data by using a nonparametric estimator of the optimal weighting matrix. This paper addresses the issue of choosing the corresponding smoothing parameter (or bandwidth) so that the resulting point estimate is optimal in a certain sense. We derive an asymptotically optimal bandwidth that minimizes a higher-order approximation to the asymptotic mean-squared error of the estimator of interest. We show that the optimal bandwidth is of the same order as the one minimizing the mean-squared error of the nonparametric plugin estimator, but the constants of proportionality are significantly different. Finally, we develop a data-driven bandwidth selection rule and show, in a simulation experiment, that the particular bandwidth chosen may yield significant second-order gains.JEL classification: C12; C13; C14; C22; C51 Keywords: GMM; higher-order expansion; optimal bandwidth; mean-squared error; long-run variance. * Department of Economics, University College London, 30 Gordon St, London WC1H 0AX, UnitedKingdom; E-Mail address: d.wilhelm@ucl.ac.uk. I thank Christian Hansen, Alan Bester, the co-editor and two referees for helpful comments.