The Wizard

You receive a message from Zelda shortly after you obtain the Master Sword, and you must hurry to Hyrule Castle.

The entrance to the upper reaches of Hyrule Castle is blocked by a Lightning Lock.

Enter the Upper Reaches of Hyrule Castle

Although there are many soldiers throwing spears and bombs to deter trespassers, the front gate of Hyrule Castle lies open. Go through the front gate, and go north to the front door of the castle. Go inside.

Go through the east door, then go up the stairs to reach the upper level. Exit the castle through the south door.

Outside, go west and you will find that the door is blocked by a Lightning Lock. Now that you have the Master Sword, you can cut through it to destroy it. Do so, then go through the door.

Get a Key

Go north from the first room, and you will be attacked by two golden Ball and Chain Troopers. If you are at full health, you can hit them with your sword beams to kill them, but it takes many hits with the beam. After you defeat them, go through the east door.

Two Sword Soldiers will charge toward you. Kill them and a chest will appear. Open it to get a key. Use it to go through the locked north door.

Get a Second Key

In this dark chamber, there is a flying Chasupa on the statue, and a Sword Soldier that charges toward you. Kill or ignore them, then go through the door in the west wall.

In this maze, go all the way north, then all the way west, and then south. At the first split, go east, and then south. At the next split, go south down the leftmost path. From there, go south, then west, and defeat the soldier that attacks. Then go north through the leftmost path to find a chest that contains a key. Go south, then east at the split, then go north. At the split, go down the southern path on the right. When the path splits again, go south, then at the split, go southeast and you will reach a locked door. Go through.

Get a Third Key

Kill or ignore the two Sword Soldiers and go up the stairs in the north wall.

Kill or ignore the Sword Soldier and Bow Soldier, and go through the door in the west wall.

Be careful not to fall off of the edge here. There are some torches spread around the room that you can light with your lamp if needed. From where you entered the room, if you want a single rupee, go south; if you want a heart and a blue rupee, go west; otherwise, go north. If you need to return to the previous room, you can go to the northwest corner and push the block to open the door. If you are ready to move on, go to the northeast corner of the room and go through the door there.

There are two Bow Soldiers and one Sword Soldier in this room. Kill the soldiers, and one of them will drop a key. Use it to unlock the north door and go through.

Get a Fourth Key

Kill the two Spear Soldiers to open the west door. Kill or ignore the two Chasupas on the statue. You can optionally check on the tile on the wall, and Sahasrahla will tell you that the Master Sword cannot physically harm the wizard, so you have to find a way to turn the wizard's magic against him. Then go west through the door.

Kill the two Spear Soldiers, then go through the south door. There are two more Spear Soldiers in this room, and two Chasupas. Kill the Spear Soldier in the middle of the room to get a key. Use it to unlock the east door and go through.

Reach the Wizard

There is a golden Ball and Chain Trooper, a Spear Soldier, and a Sword Soldier in this room. Kill or ignore them, then go north up the stairs.

You can move the leftmost statue. Push it to the left, kill or ignore the Bow Soldiers and Spear Soldier, then go through the west door.

Carefully go north up the narrow path, killing or ignoring the Sword Soldiers on the way, then go up the stairs to the north to reach the next room.

Go north to the next room and there will be a cutscene. Afterward, go north to the curtains and cut open the middle ones to reveal a hidden door. Go north through the door.

Agahnim

There will be a cutscene, and then the battle will begin. Throughout the battle, Agahnim will turn into a black orb and float to another part of the room. He has three attacks: a large, flashing energy orb; six small blue orbs in a circle; and, only when he is standing in the middle of the north side of the room, a large lightning attack.

As Sahasrahla said if you checked on the tile on the way to this room, you can't harm the wizard physically with the Master Sword. If you try, you will be zapped. Instead, you need to hit the large, flashing energy orb whenever he throws one at you. It will bounce off of your sword, and if you aim correctly, the orb will hit Agahnim and harm him. The Bug-Catching Net can also be used to knock the orb back, but it is probably easier to use your sword instead.

You can hit the six small blue orbs with your sword to break them apart, but there is a chance that one of them will hit you instead of being blocked by your shield (if you upgraded to the Red Shield). These small orbs can't harm Agahnim.

If Agahnim goes to the middle of the north side of the room, and if he doesn't turn to face you if you move to the side, he will shoot a lightning attack downward to the south side of the room. Stay near the west or east side of the room to avoid this attack.

After you have hit Agahnim with enough large orbs, there will be a cutscene, and you will be dragged into The Dark World.