Flamengo scored twice in the last eight minutes to come from behind and beat Bahia 4-3 on Sunday, but the Brazilian league match was overshadowed by accusations a Bahia player used racist language towards an opponent.
Flamengo midfielder Gerson accused Bahia's Juan Ramirez of using "unacceptable" language towards him.
"I have played a lot of professional matches but I have never come and said anything like this to the press because I've never suffered this kind of prejudice," the former AS Roma and Fiorentina player said after the game.
Video also showed Gerson remonstrating with Bahia coach Mano Menezes and the 23-year-old said the former Brazil coach " ... has to learn to respect [people]."
Bahia later announced they were investigating "the serious accusation of racism involving the Colombian 'Indio' Ramirez" and would make a statement after reaching a conclusion.
The club also said they had fired Menezes, though they did not clarify if that decision was related to Sunday's incident or their run of five straight losses.
Vitinho's winner a minute from time means Flamengo move into second place in Serie A, five points behind Sao Paulo but with a game in hand.
Bahia are one place above the relegation zone in 16th.
Reigning champions Flamengo were 2-0 up at half-time through Bruno Henrique and Mauricio Isla despite having Gabriel Barbosa sent off after just 10 minutes for dissent.
Bahia, who had lost their previous four league games, stormed back to score three times in the first 15 minutes of the second half and looked set for a stunning victory.
But Flamengo were not finished, and after Pedro chested a cross into the net with eight minutes remaining Vitinho completed the remarkable comeback in the dying moments.