The cornea of the eye differs from other mucosal surfaces in that it lacks a viable bacterial microbiome and by its unusually high density of sensory nerve endings. Here, we explored the role of corneal nerves in preventing bacterial adhesion. Pharmacological and genetic methods were used to inhibit the function of corneal sensory nerves or their associated transient receptor potential cation channels TRPA1 and TRPV1. Impacts on bacterial adhesion, resident immune cells, and epithelial integrity were examined using fluorescent labeling and quantitative confocal imaging. TRPA1/TRPV1 double gene-knockout mice were more susceptible to adhesion of environmental bacteria and to that of deliberately-inoculated Pseudomonas aeruginosa. Supporting the involvement of TRPA1/TRPV1-expressing corneal nerves, P. aeruginosa adhesion was also promoted by treatment with bupivacaine, or ablation of TRPA1/TRPV1-expressing nerves using RTX. Moreover, TRPA1/TRPV1-dependent defense was abolished by enucleation which severs corneal nerves. High-resolution imaging showed normal corneal ultrastructure and surface-labeling by wheat-germ agglutinin for TRPA1/TRPV1 knockout murine corneas, and intact barrier function by absence of fluorescein staining. P. aeruginosa adhering to corneas after perturbation of nerve or TRPA1/TRPV1 function failed to penetrate the surface. Single gene-knockout mice showed roles for both TRPA1 and TRPV1, with TRPA1-/- more susceptible to P. aeruginosa adhesion while TRPV1-/- corneas instead accumulated environmental bacteria. Corneal CD45+/CD11c+ cell responses to P. aeruginosa challenge, previously shown to counter bacterial adhesion, also depended on TRPA1/TRPV1 and sensory nerves. Together, these results demonstrate roles for corneal nerves and TRPA1/TRPV1 in corneal resistance to bacterial adhesion in vivo and suggest that the mechanisms involve resident immune cell populations.