Sonic, a blue hedgehog who can run at supersonic speeds, finds himself sought after by a tribe of echidnas for his power. His guardian, Longclaw the Owl, gives him a bag of rings that open portals to other planets. She uses one to send him to Earth while she fends off the echidnas. Ten years later, Sonic enjoys a secret life near the town of Green Hills, Montana, but longs to make friends. He idolizes the local sheriff, Tom Wachowski, and his veterinarian wife, Maddie, unaware the pair are planning to relocate to San Francisco soon, as Tom has been hired by the San Francisco Police Department.
One night, Sonic becomes upset over his loneliness when playing baseball by himself, and runs at supersonic speed as a result, inadvertently triggering an electromagnetic pulse that causes a power outage across the Pacific Northwest. Roboticist and scientific genius Dr. Robotnik is enlisted by the United States Department of Defense to uncover the source of the outage. Robotnik discovers and tracks Sonic, who hides in the Wachowskis’ shed. Tom discovers Sonic and shoots him with a tranquilizer dart, causing Sonic to drop his bag of rings through a portal to San Francisco. Tom reluctantly agrees to help Sonic before Robotnik arrives at the Wachowskis’ house and the two flee. As the pair evade Robotnik, who labels Tom a domestic terrorist, they slowly bond, with Tom learning about Sonic’s desire for a real friend.
Having discovered one of Sonic’s quills, Robotnik discovers the power in it has the potential to fuel his robots and becomes obsessed with capturing Sonic. As he tracks them down, Tom discusses his plans to leave Green Hills, and Sonic disapproves. Shortly after defeating a robot sent by Robotnik, an explosion injures Sonic. Arriving in San Francisco, Tom brings him to Maddie, who revives him. While Tom explains their situation to Maddie, Sonic receives a new pair of sneakers from Maddie’s niece. The group soon head to the tower’s roof of the Transamerica Pyramid, where Sonic’s bag of rings landed, and recover them. Robotnik arrives in a hovercraft and attacks them, forcing Sonic to use a ring to send Tom and Maddie back to Green Hills.
Sonic flees from Robotnik, who uses the power of Sonic’s quill to match his speed. The two engage in a chase across the world, ultimately returning to Green Hills. Robotnik incapacitates Sonic, but Tom intervenes, allowing Sonic to regain his strength and reclaim his lost energy. Overcoming Robotnik, Sonic defeats him by sending him to a mushroom planet. Following the incident, Tom and Maddie decide to stay in Green Hills and let Sonic live with them. The government erases all evidence of the events, including records of Robotnik’s existence. Meanwhile, Robotnik, still in possession of Sonic’s quill, begins plotting his revenge.
In a mid-credits scene, Tails, a fox from Sonic’s world, emerges from a ring portal in search of Sonic.