Copa do Brasil Wrap: Ronaldinho stars as Atletico Mineiro lose
Atletico Mineiro took the advantage in the round-of-16 tie at the Maracana when Marcos Rocha converted former Barcelona star Ronaldinho's assist in the 21st minute.
But only nine minutes later the game was level as Botafogo's Nicolas Lodeiro found a path past goalkeeper Victor.
With the scores level at half-time, an unfortunate moment from Mineiro's Leonardo Silva on 49 minutes saw the defender poke the ball into his own net to put Botafogo in front.
A strike to Rafael Marques in the 56th minute and Vitinho's goal five minutes from time sealed the game for Botafogo before Ronaldinho's brilliance on 89 minutes earned a crucial goal for Guilherme to give Mineiro a chance going into the second leg on Wednesday.
In the day's other tie, Internacional had no problems defeating Serie D side Salgueiro 3-0 at the Estadio do Vale in the first leg of their round-of-16 match.
Argentina international Andres D'Alessandro started off the scoring from the penalty spot on 49 minutes before former Manchester United forward Diego Forlan assisted Ignacio Scocco's 67th-minute goal.
Forlan made it three on 88 minutes as Internacional took a commanding lead before the second leg on August 29 at Salgueiro's Estadio Cornelio.