I think Sonic would win. Even though Mario does have fireballs, can sort of fly, and can get big with mushrooms, Sonic would wear him down with his speed, and can use his body as a weapon. He's sort of like a tiny wrecking ball.
Sonic is fast, but not strong. Mario could wet the area around him with FLUDD and that would really slow down Sonic. He may be sure-footed, but at that speed, I don't think Sonic could use his full speed. Then, there's the Invisible Cap.
Mario slowed Sonic, made himself invisible to Sonic and then he could either: 1) nail him with Fireball or 2) slam the punk to the ground. Hell, grab him, fly up and plunge back to the ground, making a hedgehog pie.
The only thing you just said that could work is slamming him. 1) Can't shoot fireballs because Mario doesn't support 2 powers at once. 2) The same reason I just gave so he can't fly. And the only way he could grab sonic is if he magically got rid those spikes on his body.