First he catches a dead donkey, then a pitcher full of dirt, then shards of pottery and glass.
The jinni explains that for the first hundred years of his imprisonment, he swore to enrich the person who frees him forever, but nobody freed him.
After four hundred years of imprisonment, the jinni became enraged and swore to grant the person who frees him a choice of deaths.
The jinni, eager to show off, shrinks and places himself back into the bottle to demonstrate his abilities.
Awed by the sight, the Sultan asks the fisherman where he got the fish and goes to the pond to uncover their mystery.
The story is classified in the international Aarne-Thompson-Uther Index as tale type ATU 331, "The Spirit in the Bottle".
[1] According to scholars Ulrich Marzolph [de], Richard van Leewen and Stith Thompson, similar stories have appeared as literary treatments in the Middle Ages (more specifically, since the 13th century),[2][3] although Marzolph and van Leewen argue that the literary treatments derive from legends about King Solomon.
[2] In the same vein, in his 2004 revision of the ATU system, German scholar Hans-Jörg Uther indicated an Oriental origin for the tale type, of Jewish and Arabic provenance.