How to battle other players across the globe?

First, Make sure you have a working internet connection, then go to the second floor of any pokemon center and talk to the Battle NPC.

Then choose whether you want a random opponent or you can also give the NPC a specific username.