With Canada seemingly headed for victory and a possible first-place finish in Group A, Cuba's Maykel Reyes scored in the first minute of added time to force a 1-1 draw.
Evan James had given Canada a 1-0 lead in the first half.
El Salvador scored in injury time to tie the United States 3-3 later Monday, clinching top spot in Group A and eliminating the Americans.
The late goal from Cuba goal ended up being huge. Instead of finishing first in Group A with seven points, Canada finished tied with El Salvador at five points. El Salvador won the group with better a better goal differential, plus-4 to plus-2.
Instead of advancing to play the second-place team in Group B, Canada will likely have to play the powerful Mexicans in the semifinals. Only the two tournament finalists advance to the Olympics.
"The players are very upset right now," said Canadian manager Tony Fonseca. "Our focus is to recover and to prepare for semifinal."
The U.S., a perennial favourite, finished with four points, while Cuba managed one.
With six points in two games and a goal differential of plus-9, Group B leader Mexico is all but assured to be Canada's opponent in the next round. That means the Canadians will have to pull out another upset to advance to their first Summer Games since 1984.
Mexico plays its final game Tuesday night against Panama.
The semifinals are on Saturday.
"We knew coming into this game it was going to be difficult," Fonseca said. "Third game in five days — it takes its toll on the players. We spoke about that and we spoke about managing the game a little better."
Canada entered the game in prime position to win Group A after a stunning 2-0 upset of the U.S. on Saturday, and they looked poised to build on that against Cuba.
Canada opened the scoring in the 24th minute when Lucas Cavallini charged the Cuban goal then passed back to James, who fired a low shot to the far corner of the net.
Russell Teibert nearly made it 2-0 on a free kick in the 70th minute, but Cuban goalkeeper Odisnel Cooper stretched to tip the ball over the net.
But Reyes tied the game in injury time after heading in a ball on a free kick past Canadian keeper Michal Misiewicz.
Canada had one last chance on a corner kick in the final minute, but couldn't conjure up a goal.
"I think today they paid a bit of a price for being young and naive," Fonseca said.