This paper develops a framework for estimation and inference to analyze the effect of a policy or treatment in settings with treatment-effect heterogeneity and variation in treatment timing. We propose a two-stage difference-in-differences (2SDD) estimator that compares treated and untreated outcomes after removing group and period effects identified using untreated observations. Our regression-based approach enables us to conduct inference within a conventional GMM asymptotic framework. It easily facilitates extensions such as dynamic treatment effects, triple differences, continuous treatments, time-varying controls, and violations of parallel trends. Simulations of randomly generated placebo laws in state-level wage data demonstrate that 2SDD outperforms alternatives in terms of precision and rejection rates. Under homogeneous treatment effects, 2SDD yields similar standard errors as TWFE regressions, unlike other heterogeneity-robust estimators. Analyzing the rate of extreme t-statistics and outlying standard errors for various methods across seven empirical applications.