The universally-used theory of Norgett, Robinson and Torrens (NRT) for calculating primary radiation damage in materials assumes that materials are homogeneous. For many engineering materials, which have rich microstructures, this assumption is poor. As there are no alternative radiation damage theories that include heterogeneity, the role of the microstructure on primary radiation damage has been neglected. Here we extend the NRT formalism to account for microstructural variations and account for the damage caused in a phase by primary knock-on atoms that are produced in another nearby phase. The new approach converges to conventional NRT at suitably large length-scales, and agrees with binary collision approximation simulations for individual phases of a microstructure. Applying the method to a ferritic superalloy, we show that the damage can vary by up to 30% from one phase to another, and up to 7% within a single phase. Substantially greater variations are predicted for more chemically heterogeneous alloys. Our new approach provides new physical insight into the interplay between microstructure and primary radiation damage.