Sir Topham Hatt, normally in charge of the railways on Sodor, is on holiday and has left Mr. Conductor along with Pac-Man, Ms. Pac-Man, Super Pac, Roger Rabbit and Babs and Buster bunny in charge. Meanwhile, Thomas and Gordon encounter an evil diesel locomotive, Diesel 10, stating that he has unfinished business on Sodor. He is planning to get rid of steam engines on Sodor once and for all. Mr. Conductor has problems of his own. The mysterious gold dust that allows him to magically teleport from place to place is running low, and without it there will be no way for anyone to travel from Shining Time to Sodor or back again. There is a lost engine that is able to travel between Sodor and Muffle Mountain using the Magic Railroad, but nobody knows where she is.
Burnett Stone, an elderly man, lives on Muffle Mountain, near Shining Time Station with Calamity Coyote and SpongeBob SquarePants, in which Stacy Jones was the manager. Unknown to everyone, he is the guardian of the lost engine, whose name is Lady. The engine crashed after an earlier encounter with Diesel 10, and ever since then Burnett, Calamity and SpongeBob have been trying to repair Lady. Even though he seems to have gotten the little engine restored mechanically, so far he has been unable to make her steam. Pac-Man, Ms. Pac-Man, Super Pa,, Roger, Buster, Babs, Percy and Thomas find out that there is a secret railway and there are magic buffers that lead to it. However, Diesel 10 overhears them. Toby the Tram Engine follows Diesel 10 and hears him telling his diesel locomotive henchmen Splatter and Dodge of his plans to destroy the steam locomotives. Diesel 10 thinks that this horrid act seems possible mainly because Mr. Conductor's whistle contains gold dust inside which he uses to travel is running out, and he is therefore becoming too weak to stop Diesel 10. Wanting to warn his friends of Diesel's plans, Toby rings his bell to distract them, only to make Diesel 10 to destroy the sheltering they were resting in, trapping them.
Burnett's granddaughter Lily visits him, and meets C. Junior, Mr. Conductor's good-natured but lazy cousin, who takes her to Sodor and introduces her to the talking engines who live there, including Thomas. Later, Thomas is assigned to transport Lily back to Burnett (with Pac-Man, his family and friends coming with them) on Muffle Mountain after inadvertently discovering the entrance of the long-abandoned Magic Railroad by an old grotto. He takes his lost truck of special Island-of-Sodor coal and arrives on the other end of the Magic Railway, located at the edge of a high cliff near the top of Muffle Mountain. Lily goes to her grandfather's house with Pac-Man and the gang, leaving Thomas stranded on the mountain. However, the ground gives way and Thomas uncouples himself from the coal-truck, falling off the cliff to the bottom of the mountain where he re-enters the Magic Railroad through another portal there.
Lily reunites with Burnett at his workshop, where he, Calamity and SpongeBob shows her, Pac-Man and the gang Lady and explains his problem getting the engine to steam. Using the Sodor coal truck, the engine eventually comes to life and makes the steam. Lily, Burnett, Pac-Man and the gang take Lady along the Magic Railroad, regenerating itself in the process. Lady comments that Burnett had never forgotten about Magic. They reunite with Thomas and find their way back to Sodor, where Diesel 10 finds them and goes after them. When Thomas and Lady cross the crumbling Viaduct, it begins to partially collapse. Lady makes it across, and Thomas gets across a 3 foot gap in the supports. After an entire arch fractures, Diesel 10 attempts to cross and brakes as hard as he could. The suspended pieces of track can't hold him due to his weight and he falls off (Even though he first manages to grab a track tie, it soon breaks), plunging into the ravine below. He lands in a barge filled with sludge and is carried away.
Thomas, Lady, Burnett, Lily, Pac-Man and the gang meet Mr. Conductor and C-Junior. They use the water from a wishing well and shavings from the rails of the Magic Railroad to make more gold dust, and the Island of Sodor and Shining Time Station are saved. C-Junior, encouraged by his success in being able to help out, offers to take a job on Sodor, and Mr. Conductor presents him with his conductor's cap so that C-Junior can now take over Mr. Conductor's role on Sodor, while Mr. Conductor says that he will now travel back to serve at Shining Time Station. In the end Pac-Man and his family and friends go home and Thomas is happily going home to Tidmouth Sheds to tell the engines about his encounter with the lost engine Lady.
Roger Rabbit, Babs and Buster Bunny, Calamity Coyote and SpongeBob SquarePants gueststar in the film.