Electronic health record systems contain clinically detailed data from large populations of patients that could significantly enrich public health surveillance. Clinical practices' security, privacy, and proprietary concerns, however, have limited their willingness to share these data with public health agencies. We describe a novel distributed network for public health surveillance called MDPHnet. The system allows the Massachusetts Department of Public Health (MDPH) to initiate custom queries against participating practices' electronic health records while the data remain behind each practice's firewall. Practices can review proposed queries before execution and approve query results before releasing them to the health department. MDPH is using the system for routine surveillance for priority conditions and to evaluate the impact of public health interventions.