Find the stronghold, open the End Portal, destroy the End Crystals and kill the Ender Dragon. Gear, both fight phases, the rewards and how to fight it again.
The Ender Dragon is the final boss of Minecraft. It lives on the main island of the End, has 200 health points (100 hearts) and is the largest mob that spawns naturally in the game.
Beating it is a three step job: find a stronghold, activate its End Portal with Eyes of Ender, then destroy the End Crystals and kill the dragon. The first kill rolls the credits and gives you 12,000 experience, enough to go from level 0 to level 68.
Most failed attempts come from missing gear, not from the dragon itself. Bring this:
The carved pumpkin is optional, but it stops Endermen from getting angry when you look at them. Wear it only when the island is crowded, since it blocks part of your view.

Craft each Eye of Ender from 1 ender pearl and 1 blaze powder. Ender pearls drop from Endermen, and blaze powder comes from blaze rods, which blazes drop in Nether fortresses.
Throw an eye into the air and it flies toward the nearest stronghold. Walk in that direction, throw another every few hundred blocks, and pick each eye back up. When an eye flies down into the ground instead of sideways, the stronghold is right below you.

Dig down carefully and search the stronghold for the portal room. It has a silverfish spawner on a staircase and a ring of 12 End Portal frames over a pool of lava. Place one Eye of Ender in every empty frame, and the portal opens once all 12 are filled.
Note: Break the silverfish spawner first, or block it with torches around it. Otherwise silverfish keep pouring out while you fill the frames.

You arrive on an obsidian platform near the main island. Bridge over, then look at the tall obsidian towers. There are 10 of them, and each has an End Crystal on top that heals the dragon whenever it flies close.
Shoot the open crystals with arrows. Two of the towers have iron cages around the crystal, and arrows can't get through those. For a caged crystal, pillar up the tower or throw an ender pearl to the top, break the bars and hit the crystal from a safe distance.
Crystals explode when they break, so never hit one standing right next to it. If you destroy a crystal while it is healing the dragon, the dragon takes 10 damage as well.

Once every crystal is gone, the dragon can't heal anymore. It switches between two phases, and each needs a different weapon.
The dragon circles the island and dives at you to knock you into the air. It also shoots purple fireballs that leave a cloud of dragon's breath on the ground. Shoot it with your bow while it circles, and step out of every purple cloud right away.
Being thrown high is the real danger. Drink a Slow Falling potion or keep your water bucket ready to land in water, and stay away from the edge of the island.
Every so often, the dragon lands on top of the exit portal in the middle of the island. It breathes fire around itself here and can't be hurt by arrows, so switch to your sword.
Stand to its side, not in front of its head, and land critical hits by jumping before each swing. A hit to the head deals full damage, while hits to the wings or body deal far less.

Keep repeating the two phases until the dragon dies. When it does, it rises into the air, breaks apart in beams of light and drops its experience.
Killing the dragon gives you several rewards at once:

Note: Clicking the dragon egg makes it teleport. To collect it, put a torch two blocks below it, then break the block under the egg so it drops onto the torch and turns into an item. A piston pushing the egg works too.
Fill glass bottles in the dragon's breath before the fight ends if you want lingering potions later. Breath only appears while the dragon is alive.
You can bring the Ender Dragon back as often as you like. Place 4 End Crystals around the exit portal, one on each side, and the towers rebuild themselves before the dragon returns.

Each new fight also spawns another End gateway, up to 20 in total. Many players repeat the fight to get extra gateways and to farm the dragon's experience.
For the gear that makes the fight much easier, see How To Get Netherite and Best Enchantments For Every Weapon, Tool And Armor Piece.