In order to gain a miraculous gourd, you must defeat 5 gods and take the subsequent boxes that they drop. Each box contains a fragment of the gourd. Once you have all 5 fragments of the gourd, you must bring them to Confucius in Twin City (437,347).
Acquiring the pieces:
There are gods in 5 locations throughout 4 different maps.
Bird Island: One god is located on the smallest island within this map, to the top left hand corner.
Ape City: Two gods are located in the Ape City Zone map. Take the Bottom left hand corner portal in ape city. Once on this map, travel north west as far as possible, to the top left hand corner of the map.
Mystic Castle: Take the boatman to mystic castle, and find the platform to the bottom right hand corner of the map (there are two platforms this could describe, the god is on the platform to the right)
Phoenix Castle: The last god is located in the Phoenix Castle Zone. Go to the bottom right hand corner of the FIRST section of the map, do NOT cross the bridge. If you see the small "village" you are in the right place, follow the portal through. Once in Phoenix Castle Zone, go to the extreme lower right hand corner (DO cross the bridge this time) to find the god.
Once you have all five boxes with the fragments, bring them back to Confucius and he will award you the miraculous gourd.