Guide:Dungeon Guardian strategies

The Dungeon Guardian is the strongest monster in Terraria and spawns when you try to enter the dungeon before defeating Skeletron, or when failing to defeat Skeletron before dawn. There is little reason to fight him, except for the Bone Key he drops.

Terrain Preparation
As he will instantly kill you when he touches you the only way to defeat him is to outrun him. Therefore you have two good options for terrain. First is simply use the whole map, by using Gravitation Potions to move around. You will fall faster than him and you can move diagonally to go even faster. The second option is a very long (single-layer) Skybridge. You will be equally fast as the Dungeon Guardian when running horizontally. If you want to outrun him make a diagonal skybridge (any blocks except platforms work for this) or build the skybridge out of Asphalt.

Aside from that, if you want to 'summon' the dungeon guardian by entering the dungeon you need a way out of the dungeon. Easiest way is to simply dig straight down and use a Gravitation Potion to get up again.

If the player has access to the Mechanic and Steampunker it is possible to build a Teleporter arena (example). This can make the fight dramatically easier, especially if the Teleporters are automated with Timers. As the Mechanic is found in the Dungeon it is however likely that this requires the player to bring materials from a world where Skeletron has already been defeated.

Last of all, you need to be in a world where Skeletron has NOT been defeated.

Gearing Up
As the Dungeon Guardian will instantly kill you, no matter so much defense that damage doesn't matter (except crits which always deal 2 damage instead of 1) there are only a few items actually useful.

Armor
If available use Frost armor, as the Dungeon Guardian is not immune against the Frostburn debuff, greatly increasing the damage. It also provides a good crit bonus. Another option would be Chlorophyte armor, as a full set summons a leaf that also shoots at the Dungeon Guardian and it also provides a crit bonus. Yet another option is to use Beetle armor with the shell along with defensive accessories and an Endurance Potion and Lifeforce Potion to give you a fairly good chance of surviving a hit from the dungeon guardian should it happen to hit you.

Weapons
Ranged weapons are the only viable type of weapon for this fight. Furthermore the weapon should have a high firing speed. Recommended is any prefix that increases critical hit chance or firing speed.
 * Some high firing ranged weapons are Chain Gun, Gatligator, Megashark, Minishark and Uzi. Combine them with Crystal Bullet for additional damage from the released fragments.
 * Bows that may be useful are the Tsunami or Pulse Bow, due to them firing multiple projectiles. Combine them with Holy Arrows for more damage (which is mainly useful if you do not make use of the skybridge method).
 * The Piranha Gun is a very easy to use ranged weapon, that deals significant damage.
 * Useful magic weapons would be Razorpine, Crystal Storm, Leaf Blower, Bubble Gun and, if you use the skybridge method, Blizzard Staff.
 * If you want to use melee damage based weapons using Vampire Knives or Scourge of the Corruptor are possibilities.
 * Although most minions are useless, due to them being to slow the Optic Staff and Tempest Staff can be helpful, due to their minions shooting bullets.
 * Flairon is effective due to the large amount of homing projectiles, firing ~17 projectiles per second.

Accessories
Prefixes for accessories should be more critical hit chance or more movement speed.
 * If you do not use Gravitation Potions, Spectre Boots as well as a Shiny Red Balloon, or any upgraded version of those items. This will be needed when you reach the end of the skybridge to jump over the Dungeon Guardian when switching direction. Furthermore you need to be able to run and reach the horizontal speed cap.
 * If you do use Gravitation Potion some item to negate fall damage or provide running may still be useful.
 * If you use any type of wings, the Frog Leg is very useful because it provides 50% increased flight speed and range.
 * Black Belt or Master Ninja Gear give you a chance to dodge an attack. This is especially useful in combination with Turtle armor and Cross Necklace.
 * Destroyer Emblem and Eye of the Golem for their increased crit chance.
 * A Mana Flower, in case you use magic weapons.
 * Optionally a Depth Meter/GPS, so you can see when you move past the 0 depth line, causing the Dungeon Guardian to spawn.

Potions

 * Gravitation Potions, in case you use that method.
 * Swiftness Potions and something to give you the Well Fed buff, to increase your movement speed.
 * Any Mana Potions if you use magic weapons.
 * Optionally some Rage Potions and potions that provide light, such as Hunter, Night Owl and Shine Potions.

The battle
Basically you just need to keep running away, keep firing and make sure your buffs don't run out. If you set up everything correctly it just comes down to skill, while no real strategy is required.