You need to have Uxie, Azelf and Mesprit on your team. When you're soaring around near Dewford, you'll find a tear in the sky. When you approach it, it should ask you if you want to enter. If you say yes then Palkia will attack you if you're playing Omega Ruby, and Dialga will attack you if you're playing Alpha Sapphire.
If you don't have the lake trio, you can find them in the Nameless Cavern, which you can find by soaring around Sootopolis. Uxie is found between 20:00 and 21:00, Azelf can be found between 21:00 and 03:59 and Mesprit can be found between 04:00 and 19:59.