A mathematical model of the contaminant transport in HVAC systems and buildings is described. The model accounts for transients introduced by control elements such as fans and control dampers. The contaminant transport equations are coupled to momentum equations and mass continuity equations of the air. To avoid modeling variable transport delays directly, ducts are divided into a large number of small sections. Perfect mixing is assumed in each section. Contaminant transport equations are integrated with momentum equations in a way that guarantees mass continuity by using two non-negative velocities for computing the mass transport between elements. Computer simulations illustrate how the model may be used to analyze and design control systems that respond to a sudden release of a toxic contaminant near a building. By coupling transient flow prediction with transient contaminant prediction, the model overcomes a number of problems with existing contaminant transport codes.