Plan of upper portions of glossopharyngeal, vagus, and accessory nerves. Image source: Gray's Anatomy (1918) / Wikipedia.
The accessory nerve is the eleventh cranial nerve. It is purely a motor nerve and differs from the other cranial nerves in that only a small part of it originates from the brain; most of the nerve comes from the spinal cord.
The cranial part of the accessory nerve, which originates from the brain, supplies many muscles of the palate, pharynx (throat), and larynx (voice-box). Damage to this part of the nerve gives rise to dysphonia (difficulty in speaking) and dysphagia (difficulty in swallowing).
The spinal part of the accessory nerve supplies some large muscles of the neck and back, notably the sternomastoid (which runs from the sternum (breastbone) to the side of the skull) and the trapezius (a large, triangular muscle of the upper back, shoulder, and neck). Damage to the spinal fibers of the accessory nerve paralyses these muscles. Such damage usually occurs as a result of surgery for cancer in which lymph nodes in the neck are removed.
Detailed anatomy (from Gray's Anatomy of the Human Body, 1918)
The cranial part (ramus internus; accessory portion) is the smaller of the two parts of the accessory nerve. Its fibers arise from the cells of the nucleus ambiguous and emerge as four or five fine rootlets from the side of the medulla oblongata, below the roots of the vagus. It runs laterally to the jugular foramen, where it interchanges fibers with the spinal portion or becomes united to it for a short distance; here it is also connected by one or two filaments with the jugular ganglion of the vagus. It then passes through the jugular foramen, separates from the spinal portion and continues over the surface of the ganglion nodosum of the vagus, to the surface of which it is adherent, and is distributed principally to the pharyngeal branch and superior laryngeal branch of the vagus. Through the pharyngeal branch it probably supplies the musculus uvulae and levator veli palatini. Some filaments from it continue into the trunk of the vagus below the ganglion, to be distributed with the recurrent nerve and probably also with the cardiac nerves.
The spinal part (ramus externus; spinal portion) is firm in texture, and its fibers arise from the motor cells in the lateral part of the anterior column of the gray substance of the medulla spinalis as low as the fifth cervical nerve. Passing through the lateral funiculus of the medulla spinalis, they emerge on its surface and unite to form a single trunk, which ascends between the ligamentum denticulatum and the posterior roots of the spinal nerves; enters the skull through the foramen magnum, and is then directed to the jugular foramen, through which it passes, lying in the same sheath of dura mater as the vagus, but separated from it by a fold of the arachnoid. In the jugular foramen, it receives one or two filaments from the cranial part of the nerve, or else joins it for a short distance and then separates from it again. As it exits from the jugular foramen, it runs backward in front of the internal jugular vein in two-thirds of cases, and behind it in one-third. The nerve then descends obliquely behind the digastricus and stylohyoideus to the upper part of the sternomastoid; it pierces this muscle, and courses obliquely across the posterior triangle of the neck, to end in the deep surface of the trapezius. As it traverses the sternomastoid it gives several filaments to the muscle, and joins with branches from the second cervical nerve. In the posterior triangle it unites with the second and third cervical nerves, while beneath the trapezius it forms a plexus with the third and fourth cervical nerves, and from this plexus fibers are distributed to the muscle.