Much of the talk before the game was about Rodinei, who was only eligible for the match because a fan paid 1 million reais ($186,000) to secure his clearance to face the club who loaned him to Inter.
But Rodinei was sent off for a clumsy stamp four minutes into the second half and Flamengo took advantage, with Gabriel Barbosa getting his sixth goal in six games after 63 minutes to secure the Mengao a vital 2-1 win.
Flamengo leap-frogged Inter to lead the Brazilian Serie A standings by two points with one game left.
Inter, who would have won their first league title since 1979 with a victory over the reigning champions, went 1-0 up after 12 minutes when Edenilson scored from the penalty spot.
At the other end of the table, Flamengo's arch-rivals Vasco da Gama were almost certainly relegated to Serie B after a 0-0 draw at Corinthians.
Vasco have 38 points but their goal difference is 12 goals inferior to their nearest rivals and so their fate was almost certainly sealed.