According to another, slightly different version, when Hanuman took a dip in sea, for cooling himself after burning Lanka; a drop of his seed got discharged, due to extreme heat generated in his body and labor by him, which fell in to mouth of a giant fish-cum-reptile like creature, whose name was Makardhwaja, thus making it pregnant.
The fish was caught by people of Ahiravana, who ruled Patala, the nether-world.
The Markardhwaja, was discovered, when stomach of fish was cut open and named after it.
Ahiravana, seeing his strength & virility gave him job of guarding, the gates of his Kingdom.