The larvae of the black soldier fly (BSFL), Hermetia illucens L. (Diptera: Stratiomyidae), are exposed to a diverse range of microorganisms within their feeding substrate that is mainly composed of decaying organic matter. In the current study, we evaluated the effect of an interaction with a Gram-negative bacterium, Pseudomonas protegens Pf-5, on the immune responses of the larvae of H. illucens. Five-day-old BSF larvae were injected with one of five doses of bacterial inoculum to assess survival. We observed dose-dependent mortality in BSF larvae to P. protegens infection, with mortality increasing with an increasing pathogen dose. Injection of more than 50 bacterial cells per larva resulted in 100 % larval mortality, while injection of one bacterial cell per larva caused only 20 % mortality. Phenoloxidase activity, an element of the immune response, correlated with the pathogen dose, increasing early for larvae injected with a high pathogen dose (i.e., 5000 bacterial cells per larva) and later for larvae injected with a low bacterial dose (i.e., one cell per larva). The expression of four genes encoding for antimicrobial peptides (AMPs), namely cecropin, defensin-A, defensin-like peptide 4, and attacin-A, displayed a treatment- and dose-specific expression pattern. Injection with either PBS (control) or different bacterial doses initially induced the upregulation of AMP genes; however, expression reduced over time in the control larvae. At high pathogen dose, all tested genes except hsp70 were consistently induced. The expression of all genes, except hsp70, was induced by low pathogen dose at 2 h, then reduced gradually and increased significantly at 15 h. These results collectively indicate that BSF larvae temporally modulate their immune responses, such as phenoloxidase activation and AMP gene expression, to combat a pathogen within their hemolymph.