The battle against the Genie is relatively simple, but the Genie's fireballs can cause a problem if Link doesn't pay attention. When the fight begins, Link must wait for the Genie to enter his bottle and then quickly stun the bottle using his sword. Link cannot hurt the Genie as long as he has his bottle to protect him, so Link must first destroy the bottle. In order to do this, Link must use the Power Bracelet to pick up the bottle and hurl it against the back wall. Then he must quickly run to the bottom wall and get ready to dodge. Three throws will destroy the bottle.
The rest of the fight is all dodging and swordplay. Link must pay attention and do his best to avoid the fireballs (the Roc's Feather comes in handy here) while attacking the Genie with his sword.
In the DX version, the genie's speech has been extended to give additional clues how to defeat him. Originally, he only said "NYAH NYAH! You can't hurt me as long as I have my bottle!", but in the DX version, once inside his bottle, he also says ". . . .! I can't move! But I am still all right. Your little sword won't break this bottle!".
↑"The Genie emerges to shoot fireballs, then retreats to the safety of his Bottle." (The Legend of Zelda: Link's Awakening Nintendo Player's Guide (Nintendo of America (1993)), pg. 37)