From Bulbapedia, the community-driven Pokémon encyclopedia.
The Mirror World (Japanese: 鏡の国 Mirror World) is an alternate dimension with strong connections to the Reflection Cave. It is nearly identical to the regular Pokémon world, with the exception that the humans and Pokémon found in the Mirror World have opposing personalities to their regular world counterparts and their physical appearances are reversed.
According to Mirror Clemont, the existence of portals to other worlds in the Reflection Cave is a myth, at least in the Mirror World. This also suggests the Mirror World is merely one of many different alternate dimensions reachable through the Reflection Cave. Also according to Mirror Clemont, people not from the Mirror World will be trapped inside the Mirror World forever once the sun has set, although the regular world's Team Rocket managed to get out somehow even though they were still in the Mirror World after sunset.
In The Cave of Mirrors!, the regular Ash and his friends went through Reflection Cave. While there, Ash and Pikachu got separated from the others. As he looked into a mirror, Ash's reflection suddenly moved and took Pikachu from his shoulder through the mirror. Ash went through the mirror after Pikachu. Once in the Mirror World, the regular Ash went outside Reflection Cave, and met up with the Mirror World counterparts of Serena, Clemont, and Bonnie. He later also met his own Mirror World counterpart, and teamed up with him to battle the Team Rocket of the regular world who had stolen both their Pikachu.
After they defeated the regular Team Rocket, Mirror Clemont realized that Ash needed to get back to his own world before sunset, or else he would be trapped in the Mirror World forever. They found the mirror through which Ash had come, but the portal was not there. It was then that Mirror Ash realized the portal opened when he wished strongly for Pikachu to return after he had lost him before. By wishing strongly to return, the regular Ash managed to open the portal. His friends were waiting on the other side at the other portal, but the two worlds started to drift apart more and more. By encouraging their regular world counterparts to hope for Ash to return, the Mirror World counterparts of Ash's friends managed to shorten the gap between the two portals. Ash managed to get back eventually, and the portals closed.