Haiti's Djimy Alexis picked himself up from scoring an own goal against Costa Rica on Monday to grab a late winner that secured top spot for his side in Group B.
Alexis was unable to get out the way in time as Alvaro Saboro's header ricocheted off him and wrongfooted his own goalkeeper to give Costa Rica a 1-0 lead in the 13th minute.
Haiti levelled in the 57th minute through Duckens Nazon's penalty and the 21-year-old Alexis completed the comeback with less than 10 minutes left, rifling the ball home from close range after good work on the left by Derrick Etienne and Alex Christian.
Haiti celebrated wildly, with Alexis running into the arms of his coach and team-mates on the sidelines.
While both teams had already secured spots in the quarterfinals, the Haitians' win sees them face Canada on Saturday in Houston, while Costa Rica takes on Mexico.
Bermuda beat Nicaragua for first Gold Cup win
Gold Cup debutant Bermuda recorded its first victory at the tournament on Monday, beating Nicaragua 2-0 in its final Group B match in New Jersey.
With both sides already eliminated, Lejuan Simmons put Bermuda ahead in the 60th minute and set up the second 11 minutes later, crossing for Nahki Wells to head home.
Nicaragua bowed out of the tournament without scoring a goal and losing all three of its matches.