During the events of Subterranean Animism, the action taken by Kanako Yasaka and Suwako Moriya towards their "industrial revolution" project for the Youkai Mountain - giving Utsuho Reiuji the powers of the god Yatagarasu in order to invoke nuclear fusion deep underground - ends up causing geysers near the Hakurei Shrine to spring forth, bringing evil spirits with them.
The group of youkai consisting of Shou Toramaru, Nazrin, Minamitsu Murasa, Ichirin Kumoi, Unzan, and Nue Houjuu is shot above the surface into Gensokyo by these geysers after having been buried and sealed in the ground for over a thousand years. With them comes the Palanquin Ship, a flying vessel captained by Murasa. Shou, Murasa, and Ichirin then vow to rescue Byakuren Hijiri from her seal in Hokkai. Unfortunately, the fragments of the floating vault, one of the pieces necessary for Byakuren's revival, were scattered all over the place by a prank of Nue's, where she planted the seeds of unknown form into the pieces(the youkai didn't know what the others were planning, but thought it would be funny if they failed). In addition, Shou loses the pagoda of Bishamonten - the second piece necessary for unsealing the monk - and sends Nazrin to find it.
The story of Undefined Fantastic Object starts in earnest in early spring, after the snow begins to melt, with rumors around Gensokyo of a strange flying object in the skies. Believing the Palanquin Ship to be a treasure ship, Reimu Hakurei and Marisa Kirisame are prompted to chase after it. In turn, they are followed by Sanae Kochiya.
The heroine first runs into Nazrin, who is busy searching for the pagoda using her dowsing rods. Since the heroine has already collected some of the pieces of the floating vault (in the form of perceived UFOs), Nazrin decides that the heroine is worth the effort to fight. However, she ultimately loses, and manages to escape in the end, settling on finding just the pagoda. It is known that she finds it between now and stage 4 or 5 at a second-hand shop, which could be referring to Kourindou.
Still chasing the flying ship, the heroine then meets Kogasa Tatara, a youkai with no relevance to the story. After the youkai fails to scare the heroine, she is promptly defeated in a high-speed battle.
Once the heroine reaches the Palanquin Ship, she meets Ichirin and Unzan, who are standing guard outside the ship itself. Many fairies and youkai have been swarming around because of the rumors that there is treasure on board, but Ichirin assures the main character that this is not the case. The heroine beats the pair and enters the ship.
Inside the ship, the heroine has her first encounter with Nue, who is concealing her true form at the moment. After she retreats, the heroine meets the captain, Murasa, who reveals that the ship is currently on its way to Makai under autopilot. The main characters generally react poorly to this, though no further mention is made of the older Touhou games. Murasa attempts to battle the heroine, again in order to wrest the fragments of the floating vault away, but in the end she assumes that the heroine is on their side and is trying to help.
Once in Makai, the heroine disembarks, only to be overtaken by Nazrin once again. The mouse youkai has found the pagoda, and decides to test it out before giving it to her master, Shou. The heroine beats the two of them, and finally decides to break the seal on Hokkai out of pure curiosity.
After the seal is broken, Byakuren appears to the heroine. A friend to all youkai and humans, she and the main character have a battle of words, but one way or another, they end up fighting. Once the heroine wins, it is implied that everyone leaves Makai(and Byakuren is not sealed away again).