They have a low-key bromance for sure.
Sonic and Mario go way back as competing poster boys for some of the first Nintendo and SEGA console systems. YouTube channel DidYouKnowGaming? recently broke down the two character’s rivalry over the years, and some of the games that brought them together as competitors.
In the video you learn that Sonic was created for the sole purpose to compete against Mario in the console market back during the Genesis’ release in the late 80s. After the financial failure of the Dreamcast system, SEGA left the console market and became more friendly with Nintendo, adopting a publisher relationship that allowed Sonic titles to release on numerous Nintendo consoles.
Sonic and Mario finally came together right before the 2008 Beijing Olympic games through Mario & Sonic at the Olympic Games back in 2007. The series continued on with games featuring Mario, Sonic and friends battling it out at the London 2012 Olympics, the Sochi 2014 Olympics, and Rio 2016 Olympics.