After going to the moon and talking to the Majora's Mask kid, you will face the final boss, Majora.
When you are ready, talk to the kid under the tree to start the final battle of the game. The first form is Majora's Mask. The mask itself floats around, trailing small tentacle-like cords. Keep your shield raised to avoid its attacks. Its back is vulnerable. If you are wearing the Fierce Deity's Mask, just hit Majora's Mask with your sword beams. Otherwise, stand below the mask and wait for it to start spinning vertically, then hit it with an arrow. Or if the mask comes close to you, you can do a spin attack to knock it back. You can hit it with your sword if it is stunned.
After you have done enough damage, the dungeon boss masks will come out of the wall and start floating around. You can kill them with sword beams as Fierce Deity Link. Or you can hit them with a couple of Light Arrows. You can also reflect Majora's laser at the boss masks to get rid of them. The laser will also damage Majora. After you do enough damage to Majora's Mask, it will change form.
The mask grows legs and arms, and a third eye. This bizarre form can run very quickly around the room and will do various dances. If you are in Fierce Deity form, just hit Majora's Incarnation with sword beams until it changes form again. Otherwise, try keeping your shield raised the whole time, except when you attack. Majora's Incarnation can also shoot a barrage of energy orbs at you. You can block these with your shield, but they are very quick, so it is hard to avoid if you don't already have your shield up. Stay in one place with your shield raised, and try to stab Majora when it runs past. Then while it is stunned, run over and hit it with your sword. You can also hit it with Light Arrows if you have good timing. After you have done enough damage, Majora transforms into Majora's Wrath.
The mask becomes more muscular and finally grows a head. It can whip with its tentacle cords from its hands. It may also spin around while whipping. Don't get too far away because Majora can grab you with the whips and throw you. Don't get too close or Majora will kick you. Majora can also jump backward away from you if you get too close.
If you are Fierce Deity Link, just hit it with sword beams. Otherwise, if you are running low on arrows, break the jars in this room now before Majora's Wrath breaks them with the whips. Raise your shield to block the whips. Then shoot Majora with Light Arrows when it is not attacking you. Hit it with your sword while it is stunned. You can also try to approach Majora when it is near a wall and hit it with your sword when you get close enough. However, this puts you at risk of getting grabbed and thrown by the whips.
After you have done enough damage, Majora throws out spinning blade traps that go around the room and eventually explode. You can bounce them away with your shield. Stay near the wall to avoid them more effectively.
Keep stunning and hitting Majora's Wrath until it dies. CONGRATULATIONS! Enjoy the ending!