Injecting the insect pathogenic bacterium Photorhabdus luminescens into the blood system of the model lepidopteran insect Manduca sexta induces nitric oxide synthase (NOS) expression in the fat body and blood cells (haemocytes), whereas following oral ingestion of bacteria NOS expression is limited to the gut. We used RNA interference to knock-down expression of NOS throughout the insect. Preventing NOS induction in this way adversely affected the survival of orally infected insects and caused a significant increase in the number of bacteria crossing into the haemolymph. By contrast, knock-down of NOS had no effect on the mortality rate of insects infected with P. luminescens by injection. Pharmacological inhibition of NOS decreased both nitric oxide (NO) levels in the gut wall and survival of orally infected insects, whereas elevation of gut wall NO using an NO donor increased survival of NOS silenced caterpillars. Together, our results imply that induced synthesis of NO is important in mediating insect immune defence against the pathogen by inhibiting transfer of bacteria across the gut wall.