Ash and friends arrive at Moro Island where there's an Orange League trophy from 300 years ago on display at the museum. Only it was stolen by (who else?) Team Rocket. They follow them out to see when a thick fog appears and out of nowhere a ghost ship does too. After team Rocket tries (and fails) to get the trophy back Haunter posseses Meowth so it can speak with Ash and Friends about why the trophy should stay with them. Gastly provided illusionary visual aids making them experience the sensation of traveling back in time. They see the history of the captain, how he perished and how 300 years later deep-sea explorers took his most prized possession and unknowingly awaken Gastly and Haunter. Gastly also shows Ash and co. that the captain was a great Pokémon trainer and he had earned the trophy. After seeing this Ash agreed that the trophy should go back to its rightful owner. After they get off the ship it floats away into the heavens, and thus, Ash and friends continue on their journey.
This is the second episode where a Pokémon used Meowth to speak through it by possession. The first being IL019, Tentacool and Tentacruel.
The Orange League was founded over 300 years ago, given the existence of a trophy from that long ago. It is unknown how this compares to the other Leagues in Kanto, Johto, Hoenn etc.
Despite the ship sinking violently in a storm, the trophy and Gastly and Haunter's PokeBalls were still neatly arranged on the table when the divers found them.
For some reason, the divers that took the trophy from the ship completely ignored the two PokeBalls right in front of it, despite being of historical value just by their presence on the shipwreck.
Gastly and Haunter's story omits the ultimate fate of the Captain after his sink sank, although he has clearly died by the time they are awakened.
Gastly and Haunter were shown to be kept within modern PokeBalls despite being from 300 years ago. However, Pokemon 4Ever - Celebi: Voice of the Forest would show trainers such as Samuel Oak using primitive wooden-looking PokeBalls only 40 years ago, making the regular red/white PokeBalls a relatively recent invention.