AUSTIN (CBSDFW.COM/CNN) – For years he had suffered from splitting headaches then Texan Gerardo Moctezuma got a mind blowing diagnosis — there were tapeworms in his head.

The headaches that often caused Moctezuma to vomit or pass out were being caused by tapeworm larvae that had taken up space in his brain.

Neurosurgeons at Austin’s Ascension Seton Medical Center said the cyst of tapeworms could’ve killed the 40-year-old.

An MRI revealed life-threatening pressure in Moctezuma’s head, because the larvae had became lodged in the brain’s fourth ventricle and filled with cerebrospinal fluid. The condition is called neurocysticercosis.

Doctors think the parasite entered Moctezuma’s body while he was living in Mexico. But he moved to the U.S. more than 14 years ago — that means the tapeworm larvae could have been living in his body for more than a decade.

Tapeworms typically take up residence in human’s intestines and are a fairly uncommon ailment in the U.S.

Moctezuma underwent emergency surgery in Austin to remove the tapeworm larvae. The operation involved opening part of his skull, near the brain stem, and taking out the cyst in one piece. He has made a full recovery and is now living headache free.

(© Copyright 2020 CBS Broadcasting Inc. All Rights Reserved. The CNN-Wire™ & © 2020 Cable News Network, Inc., a Time Warner Company contributed to this report.)