Assessing Hardy-Weinberg equilibrium (HWE) is often employed as an important initial step for genotype data quality checking in genetics studies. Tests for HWE often assume that the genotypes are randomly sampled from the general population. However, in many human genetics studies, subjects are ascertained through their disease status, and affected individuals (and their relatives in family-based studies) are overly represented in the ascertained sample than in the general population. As a result, when a marker is associated with the disease, the type I error rate in the HWE tests can be inflated, leading to false exclusion of associated markers from future analysis. Here we develop a general likelihood framework that allows assessment of departure from HWE while taking into account potential association with the disease. Our method can differentiate HWE departure caused by disease association from departure caused by other reasons, such as genotyping errors. The framework can be used for various data structures, including unrelated cases and controls, nuclear families with one or more offspring, or a mixture of them. The type I error rate of our test is under control for a broad range of scenarios. For case-control data, compared to the traditional HWE test that uses only controls, our test is more powerful to detect HWE departure for common diseases and has comparable power for rare diseases. For case-parents trios, our test is more powerful than the traditional HWE test that uses parents only. Genet. Epidemiol. 2008. © 2008 Wiley-Liss, Inc.