The nasopharynx is innervated by a pharyngeal branch of the maxillary nerve [V2] that originates in the pterygopalatine fossa and passes through the palatovaginal canal in the sphenoid bone to reach the roof of the pharynx.
The oropharynx is innervated by the glossopharyngeal nerve [IX] via the pharyngeal plexus.