(NOTE: this is only one variation of the story - their are many variations, with varying lengths of faithfulness to the original, if anyone knows the original tale please add it to this profile as this version likely misses some of the story's plot.)
The Jinni, also sometimes called the Djinni, is the chief antagonist of the Arabic fairy tale "The Fisherman and the Jinni" which was made popular in the famous collection of Arabian folklore known as A Thousand and One Arabian Nights (also known as "Arabian Nights" and "A Thousand and One Nights".
This conniving magical spirit was imprisoned in a bottle with an imprinted Seal of Solomon on it for centuries and had grown insane as a result, making a promise to kill whoever released him - granting them only the choice to choose the manner by which they would die: however when the murderous jinni was released by an unwary fisherman he was outsmarted by the quick-thinking fisherman - who taunted the djinn by claiming that he could never fit back into the bottle again, the jinni (being a prideful spirit) at once returned to the bottle to prove the fisherman wrong and was sealed back inside.
After this, the fisherman tossed the bottle back into the sea and the jinni was never heard of again - presumably he is still floating somewhere in the ocean or has been released by another unwitting victim. In some versions of the tale, before the fisherman could tossed the cursed bottle into the ocean, the djinni pleaded with him from inside the bottle and offered a bargain that he could grant him free wishes in exchange for the spirit's freedom, so the two struck a deal and they both lived and prosper.