Based on the new movie. Some slight spoilers.
Sonic has been secretly living in Canterlot for the past decade; after a moment of frustration he has been found by Twilight Sparkle in an incident that causes a power surge knocking out power all across Canterlot and beyond. Twilight ends up befriending Sonic and has to help him when they draw the attention of the military organisation G.U.N. and especially the eccentric and pure evil Dr Robotnik.