Once you bring together all 23 masks (the last one is coming), along with the four temple boss masks, you can once again confront Skull Kid. If you don't have all the 23 masks yet, you still can complete the game, but you won't get the 24th mask. Once more, it is at midnight on the third day that you can get in Clock Town's Clock Tower. Before that, make sure you have some arrows, buy 10 Bombchu in the Bomb shop, one or two Red Potions, as well as (mainly for N64) a Chateau Romani.
Climb the little slope leading to the Clock Tower balcony, then climb the stairs towards the Clock Tower roof to meet Skull Kid again. Tael asks her sister to call the four giants. After the cutscene, play the Oath to Order. The giants come, grab the moon and stop it from falling. The fairies have a discussion about Skull Kid. Then the Mask of Majora leaves Skull Kid's body and gets inside the moon to consume everything! You decide to get him!
You find yourself in a beautiful park with a tree. Get close to the tree and look at the four kids, all wearing a mask representing the bosses and another kid with the Majora's Mask. If you speak to him first, you will be directly taken to the final encounter that you can win, but there is more to do before, such as getting the 24th final mask.
You can talk to the kids in any order you like, I chose the chronological one.
So to begin with, talk to the child wearing an Odolwa Mask and give him a mask (keep the Bunny Hood as long as possible). He proposes to play hide-and-seek. You are now in a kind of mini-temple. As Deku Link, cross the room using the Deku flowers. To avoid the spinning spiked log, dive and stay in one of the flowers, then glide towards northeast and pick up the Piece of Heart. Then go back towards the spiked log and sink in the yellow flower (which allows a higher take off). Glide towards northwest and open the door. Remove your mask, talk to the child again and give him another mask.
Next talk to the kid wearing a Goht Mask and give him two masks. As Goron Link, cross the room while rolling and bouncing on the open chests, then stop near the two magic jars. (Stand right on the line in the middle of the path, then release the joystick once the first hole is crossed to roll automatically). Watch out for the light circles/eye switches which would take you back to the entrance. Walk to the right on the bridge towards the Gossip stone, then go straight on, walk a little on the left and turn around. Roll following the path, cross the hole and stop yourself. Go ahead, refill your magic power with the three pots, then roll straight forward to cross three holes, bounce on the open chest and cross another a hole until you see a Piece of Heart. Pick it up, then roll up to two other magic jars and go back towards the Gossip Stones. Then go straight ahead and roll (from the beginning of the bridge to get enough momentum) towards the door. Open it, talk to the kid again and give him two more masks.
If you fall after picking up the Piece of Heart, do this: From the entrance roll up to the magic jars. Walk right on the bridge towards the Gossip stone, then turn left and roll towards the door.
Next talk to the kid with a Gyorg Mask and give him three masks.
3DS: Wear the Zora Mask, then jump into the water and dive to the bottom. Hit the diamond underwater, then swim quickly forward and at the junction, take the left tunnel (where there are fishes). Then when the gate is in sight and that you are close to the updraught, swim down a little and push the joystick upwards to leap out from the water and land on dry land before the gate gets down. Open the door, break the magic jar, then jump into the water and hit another diamond. Again, swim quickly forward, take the right tunnel (with fishes in front), swim close to the bottom, jump out of the water before the gate closes and open the door. Jump into the water once more. Now if you want the Piece of Heart, there is no need to activate the diamond. Swim quickly, choose the middle tunnel, go on swimming, leap out from the water, pick the Piece of Heart, then come back to the entrance of this mini-temple through the black tunnel. To reach the kid from the previous point, dive, hit the diamond, swim quickly, choose the upper tunnel, leap out from the water, get back some magic power, then dive again, swim quickly and leap out before the gate closes! (From the start, the path is: left, right, up and forward.) Then open the door.
N64: Dive and try to walk on the water bottom. There are several paths to get the Piece of Heart: for example, go on your left on the first intersection, then left, right and left. Surface, take the Piece of Heart and dive in the basin behind to go back at the beginning. To find the kid there are other ways, such as, left, left, right, right or left, right, left, right.
Talk to the kid again and give him three additional masks.
Now talk to the kid wearing a Skorn Mask and give him four masks. Open the door, fight off the lizard using your sword (one or two strikes are enough with the Great Fairy Sword) and open the next two doors. Wear your Bunny Hood if you still have it and defeat the Garo Master still with your sword. Then throw your Hookshot at the chest to reach it, take the arrows inside and open the next two doors. Fight the warrior like the previous one always using the Great Fairy Sword if you have it, then pick up the Bombchu in the chest. Find a place where the wall is cracked on the right (saying that the door is to the south), then go towards the left wall, stand close fitting to it and look at this wall. (So the crack must be right behind your back). Use one Bombchu to blow it up (try not to waste them), then fire an arrow at the eye to make a ladder appear. Climb the ladder and open the door. Pick up the Piece of Heart then look for a crack in the ceiling. This time, stand against the left wall (your back towards the wall) with the crack in your axis and use another Bombchu to open it. Next, shoot a fire arrow at the eye and open the door. Talk with the kid again and give him your last four "normal" masks.