After getting past the monster horde, Ghirahim will transform and attack you.
Phase 1: Floating Platforms
Ghirahim will create floating platforms and you have to fight him without getting knocked off the edge. Hit him repeatedly with forward thrusts and upward and downward slashes (side slashes won't push him toward the edge). If he reaches back to punch, jump to the side or do a Shield Bash. If he blocks with his arms crossed, hit from the direction farthest from his crossed arms. Keep hitting him until you knock him off the edge. When he falls down to the lower platform, target him and do a fatal blow.
In the next phase, use the same strategy. Once he gets close to the edge, he will have purple energy on his hands. Hit in the proper direction to avoid touching his hands. Otherwise, he will knock you toward the edge. If he hits you back, use a Shield Bash to knock him back again. When he falls to the next platform, use a fatal blow.
On the next platform, he may put his arms in front of him, which means that he is preparing to do a spin kick. Do a Shield Bash to block this.
Repeat this strategy until he ends up on the ground.
Phase 2: Hit the Diamond
Wait for Ghirahim to attack with his sword, and use a Shield Bash to deflect it. Then do a forward thrust to hit the diamond on his chest.
Sometimes he might transport himself behind you. Turn around quickly and be prepared to Shield Bash if this happens.
He may sometimes reach back and shoot energy at you from his sword, much like a Skyward Strike. Jump to the side to avoid it. Alternatively, you can hit the energy with your sword by slashing it in the same direction to knock it back toward him. He might knock it back toward you, so be prepared for a dead man's volley.
If he throws daggers at you, knock them back or jump out of the way, or use your shield to block them.
Otherwise, repeat the strategy of hitting his sword until he knocks you back, doing a Shield Bash, then doing a forward thrust to stab his chest repeatedly.
Phase 3: Break the Sword
Ghirahim will take out a larger sword. Use a Shield Bash when he swings it at you. The sides of this sword are weak, so when he holds it in front of himself, slash from a perpendicular direction to damage it. For example, if he is holding it horizontally, hit it vertically. He will rotate the sword after a while, so don't be hasty. You need to change your attack direction to continue damaging the sword until it breaks. If you take too long, he will jump back and repair his sword.
Once you have destroyed the large sword, do a forward thrust to hit him. Repeat this strategy until you defeat him.
After you defeat him, there will be a long cutscene. Afterward, you can save the game at the Bird Statue. If you want to heal up, you can use the air vents to go up to the Sealed Temple and sit on the stool in the area where you can plant (or have already planted) a sapling. If you need supplies, you can use the Gate of Time to return to the present and stock up on supplies, potions, fairies, or whatever else you might need.
NOTE: You might want to save and quit, then go to the game select screen and make a copy of your current saved game. You'll see why after you beat the game.
If you went back to the present, go back through the Gate of Time to return to the past. Go to the bottom of the pit, and step into the dark circle to begin the final boss fight.