If there are costs involved with the maintenance of pathogen resistance, then higher investment in this trait is expected when the risk of pathogenesis is high. One situation in which the risk of pathogenesis is elevated is at increased conspecific density. This paper reports the results of a study of density–dependent polyphenism in pathogen resistance and immune function in the mealworm beetle Tenebrio molitor. Beetles reared at high larval densities showed lower mortality when exposed to a generalist entomopathogenic fungus and a higher degree of cuticular melanization than those reared solitarily. The degree of cuticular melanization was a strong indicator of resistance, with darker beetles being more resistant than lighter ones regardless of rearing density. No differences were found between rearing densities in the levels of phenoloxidase, an enzyme key to the insect immune response. The results show that pathogen resistance is phenotypically plastic in T. molitor, suggesting that the maintenance of this trait is costly.