Answer: Probable anisakid (Anisakis sp., Pseudoterranova sp., or Contracaeceum sp.)
There was a lot of great discussion on this case! While we can't definitively rule out a migratory immature Ascaris lumbricoides (crawling up from its usual intestinal location), the size of the worm, morphology, and patient history are most consistent with this being an anisakid larva. Anisakiasis occurs in humans following consumption of undercooked fish or seafood containing coiled anisakid larvae. The larvae cannot mature in humans but still have the potential to cause significant problems for their unintended human host. In the 'best case scenario', the larva dies and is passed in stool. If seen by the patient, it may be submitted to the laboratory for identification. A less optimal scenario is what was seen in this case where the live larvae crawls up the esophagus and is 'coughed up' or expelled out of the mouth. While no doubt disturbing, this is still better than the alternative, in which the larva burrows into the gastric or intestinal mucosa, causing significant pain for the host. If the larva is not immediately removed, the patient may experience symptoms for an extended period of time until the larva dies and is absorbed by the host. Rarely, the larva will penetrate the wall of the stomach or intestine and enter the peritoneal cavity, wreaking further havoc. A final, but equally important, complication of exposure to anisakid larvae is development of an allergy to anisakid proteins. This can occur regardless of whether the larva is alive or dead. Sensitized individuals must avoid anisakid-infected fish or risk experiencing serious allergic, or even anaphylactic, reactions, upon re-exposure.
Anisakid larvae can be identified by a few features: they are ~3 cm in length, have 3 fleshy lips just like A. lumbricoides, and also have a very small 'boring' tooth on the anterior end (which can be very difficult to see). Some species also have a posterior spicule called a mucron which is easier to identify. Ascaris doesn't have a boring tooth or posterior mucron, so these are helpful features when seen. Unfortunately the posterior end was damaged during removal so we weren't able to examine it.
What I found to be very interesting about this case was the history of hives, suggesting an allergic reaction to the larva. The time frame of symptoms was also interesting - the patient experienced hives for ~ 1 month before expelling the worm, which indicates that either the larva was present all of that time without causing any gastrointestinal symptoms, or the patient had ongoing exposure to anisakids through his diet. I'd be curious to know - have any of my readers run into a similar case? This is actually the second case I've seen where the patient had been symptomatic for several weeks after presumed exposure and before expelling the larva. This leads me to think that some larva can exist in the host for weeks without burrowing into the gut lining. Please let me know what your experience has been!