Microsporidia comprise a phylum of over 1400 species of obligate intracellular pathogens that can infect almost all animals, but little is known about the host response to these parasites. Here we use the whole-animal host C. elegans to show an in vivo role for ubiquitin-mediated response to the microsporidian species Nematocida parisii, as well to the Orsay virus, another natural intracellular pathogen of C. elegans. We analyze gene expression of C. elegans in response to N. parisii, and find that it is similar to response to viral infection. Notably, we find an upregulation of SCF ubiquitin ligase components, such as the cullin ortholog cul-6, which we show is important for ubiquitin targeting of N. parisii cells in the intestine. We show that ubiquitylation components, the proteasome, and the autophagy pathway are all important for defense against N. parisii infection. We also find that SCF ligase components like cul-6 promote defense against viral infection, where they have a more robust role than against N. parisii infection. This difference may be due to suppression of the host ubiquitylation system by N. parisii: when N. parisii is crippled by anti-microsporidia drugs, the host can more effectively target pathogen cells for ubiquitylation. Intriguingly, inhibition of the ubiquitin-proteasome system (UPS) increases expression of infection-upregulated SCF ligase components, indicating that a trigger for transcriptional response to intracellular infection by N. parisii and virus may be perturbation of the UPS. Altogether, our results demonstrate an in vivo role for ubiquitin-mediated defense against microsporidian and viral infections in C. elegans.