Mega Evolution, introduced in Pokémon X and Y, is a way for certain Pokémon to temporarily "Mega Evolve" during battle, drastically boosting their fighting abilities. For instance, Blastoise can Mega Evolve into Mega Blastoise. Mega Pokémon return to their original forms after the battle ends or after being knocked out.
This time around, Mega Evolution is only available after completing the main story, and after acquiring the Key Stone from a pair of Kalos travelers.
Preparations for Mega Evolution
Besides the all-important Key Stone, a Pokémon must be holding their unique Mega Stone before they can Mega Evolve. For instance, Alakazam must hold the Alakazite. Mega Stones can be acquired by exchanging BP earned from the Battle Tree or other means.
Once the conditions are met, you can make a Pokémon Mega Evolve by selecting (or tapping) the big "Mega Evolve" button towards the left side of the bottom (touch) screen while selecting a Pokémon's moves. After that, you may proceed to select a move.
Your Pokémon will immediately Mega Evolve at the beginning of the current turn, before using the move that you selected.
Mega Evolution Rule
Just like Z-Moves, you can only utilize Mega Evolution once during an entire battle--and this applies for your entire party. In addition, since Z-Moves and Mega Evolution both require a hold item, a single Pokémon can't Mega Evolve and use a Z-Move at the same time. It's one or the other!
Although Z-Moves and Mega Evolution share some similarities, their uses are profoundly different. Most notably, Mega Evolution changes a Pokémon's stats and can even change their Type(s) and Ability. In addition, unlike Z-Moves, Mega Evolution lasts longer than a single turn (unless your Pokémon is KO'd straight away).
Therefore, it's often beneficial to Mega Evolve ASAP to immediately buff up your Pokémon or take advantage of a superior typing or Ability. Meanwhile, if you're at a disadvantage, don't hesitate to switch out your Mega Pokémon--they will remain Mega Evolved when you bring them back in. Or you can delay Mega Evolution until the threat is clear.