Its main, iconic section, where Freddie Mercury sings famous lyrics like "Is this the real life? Is this just fantasy?", is mostly in the key of E-flat major. However, the song starts and ends in F major.
As you correctly pointed out, there is a section before the guitar solo that has both major and minor chords. It primarily alternates between F major and D minor, creating a bittersweet harmonic feel at that moment in the song.