Brazil Serie A Wrap: Palmeiras survive
The three teams were battling to secure 16th place as the curtains were closed on the campaign and Palmeiras ' 1-1 draw at home to Atletico PR was enough to ensure they avoided relegation.
That situation did not look a formality at the Allianz Parque when Potiguar put the visitors ahead in the 10th minute.
However, Palmeiras were awarded a penalty in the 19th minute and Henrique held his nerve to level the scores from 12 yards.
Bahia's hopes were extinguished as they let a two-goal lead slip in a 3-2 loss at Coritiba.
Strikes from Henrique and Romulo put the visitors in a promising position after 26 minutes, but Ze Eduardo halved the deficit in the 35th minute.
When Dudu equalised five minutes from the end Bahia's hopes were all but over and Keirrison added further salt to the wounds with a winning goal deep into injury time.
Vitoria were also sunk by a late goal in their 1-0 defeat at home to Santos.
With the game seemingly heading for stalemate - which would not have been enough to save Vitoria - Thiago Ribeiro scored in the fourth minute of injury time to consign the hosts to their fate.
Elsewhere, champions Cruzeiro rounded off their campaign with a 2-1 victory over Fluminense, as Nilton and Marcelo Moreno goals cancelled out Fred's opener, while second-placed Atletico Mineiro drew 0-0 at already-relegated Botafogo.
Sport Recife rounded off their campaign with a 1-0 win at home to Sao Paulo, 10-man Flamengo earned a 1-1 draw at Gremio and a brace from Erik helped Goias defeat Chapecoense 4-2 and climb to 12th.
On Saturday, a late fightback from Internacional saw them beat Figueirense 2-1 and secure the third and final automatic qualifying spot for the Copa Libertadores.
Pablo's 50th minute opener put the hosts ahead at the Estadio Orlando Scarpelli, but Rafael Moura levelled with three minutes left on the clock before Wellington Silva grabbed a dramatic winner in the fifth minute of injury time.
That meant that Corinthians were forced to settle for fourth and a place in the qualifying rounds for the Copa despite their 2-1 win over rock-bottom Criciuma.