Spoiler warning: this article may contain major plot or ending details.
Palkia was originally a Pokémon resident of Spacial Rift until recently, when the main character comes from the future and gets attacked by Darkrai. This caused a distortion in the space, and outraged Palkia, who drags the main character and his partner to Palkia's domain, Spacial Rift. There, he intends to destroy the two characters; however, the two manage to defeat Palkia, and with Cresselia's assistance enter his dream. Palkia reveals that the two characters are distorting space to the point that not even he can control it.
Cresselia then arrives to finish off the characters, but Palkia notices that they aren't malicious or evil, contrary to Cresselia's statements. He starts to get suspicious, and his suspicions are confirmed when the real Cresselia saves the characters from Darkrai's secret's plan to eliminate them. They then learn that Darkrai was the one who was distorting space, and Cresselia pulls them from the nightmare.
After the characters and Cresselia defeat Darkrai at Dark Crater, he plans to escape into a dimensional hole to follow his goal to cast the world in darkness. However, Palkia arrives and, infuriated at Darkrai's wicked scheme, blasts Darkrai just after he entered the dimensional hole. He explains to the player and partner that Darkrai was not killed, but like the player, his memories were erased, as well as his evil personality, and that he became a noble being, and the dimensional hole sent him somewhere random around the world.
Later, the player can recruit Palkia at Spacial Rift.
As Palkia can control the space itself, Spacial Rift's exit is hidden, thus requiring the player to defeat Palkia at first. This can be confirmed by losing against Palkia before defeating Darkrai.