Objective: To investigate vagotomy, the severance of the vagus nerve, and its association with mental disorders, as gut-brain communication partly mediated by the vagus nerve have been suggested as a risk factor. Methods: Nationwide population-based Danish register study of all individuals alive and living in Denmark during the study period 1977-2016 and who had a hospital contact for ulcer with or without vagotomy. Follow-up was until any diagnosis of mental disorders requiring hospital contact, emigration, death, or end of follow-up on December 31, 2016, whichever came first. Data were analyzed using survival analysis and adjusted for sex, age, calendar year, ulcer type, and Charlson comorbidity index score. Results: During the study period, 113,086 individuals had a hospital contact for ulcer.Of these, 5,408 were exposed to vagotomy where 375 (6.9%) subsequently developed a mental disorder. Vagotomy overall was not associated with mental disorders (HR: 1.10; 95%CI: 0.99-1.23), compared to individuals with ulcer not exposed to vagotomy. However, truncal vagotomy was associated with an increased HR of 1.22 (95%CI: 1.06-1.41) for mental disorders, whereas highly selective vagotomy was not associated with mental disorders (HR: 0.98; 95%CI: 0.84-1.15). Truncal vagotomy was also associated with higher risk of mental disorders when compared to highly selective vagotomy (p = 0.034). Conclusions: Overall, vagotomy did not increase the risk of mental disorders; however, truncal vagotomy specifically was associated with a small risk increase in mental disorders, whereas no association was found for highly selective vagotomy. Thus, the vagus nerve does not seem to have a major impact on the development of mental disorders.