I have heard that mega evolution are removed from the Pokemon when the battle ends and when the Pokemon faints. but what if you win in the battle with a mega Pokemon then you encounter another trainer battle, will that Pokemon still be mega?
Any Mega Evolved Pokemon will revert back to its normal form
when a battle ends, win or lose.
Source - Experience