This study was conducted to investigate space and time clusters of highly pathogenic avian influenza A (H5N1) virus infection and to determine risk factors at the subdistrict level in Thailand. Highly pathogenic avian influenza A (H5N1) was diagnosed in 1890 poultry flocks located in 953 subdistricts during 2004–2007. The ecologic risk for H5N1 virus infection was assessed on the basis of a spatial‐based case‐control study involving 824 case subdistricts and 3296 control subdistricts from 6 study periods. Risk factors investigated in clustered areas of H5N1 included human and animal demographic characteristics, poultry production systems, and wild birds and their habitats. Six variables remained statistically significant in the final model: flock density of backyard chickens (odds ratio [OR], 0.98), flock density of fighting cocks (OR, 1.02), low and high human density (OR, 0.60), presence of quail flocks (OR, 1.21), free‐grazing duck flocks (OR, 2.17), and a poultry slaughterhouse (OR, 1.33). We observed a strong association between subdistricts with H5N1 virus–infected poultry flocks and evidence of prior and concomitant H5N1 infection in wild birds in the same subdistrict.