The Finnish forward struck with nine seconds left on the clock to snatch a 3-2 victory for the hosts in front of a fanatical home crowd in Helsinki.
Canada were also packing their bags after going down 4-3 to Slovakia, and Sweden lost by the same score after a late Czech Republic goal in Stockholm ended their interest in the competition.
After a group stage that was short on surprises, the world ice hockey championships exploded into life as the knockout games began.
Having beaten Slovakia 3-2 in the group stage, the Canadians had what appeared to be a routine encounter on their way to the semis but it quickly became apparent their opponents had not read the script as they jumped out to a 2-0 lead in the first 10 minutes.
Canada pulled one back before the end of the first period and upped the tempo in the second, scoring twice and outshooting the Slovaks 17-7 as they took a one-goal lead into the final period.
But again the Slovaks struck back and Milan Bartovic set up a tense finish when he equalised with less than seven minutes to play.
With two and a half minutes remaining Canada's Ryan Getzlaf received a match penalty for kneeing and player and the Slovaks punished his indiscretion as Michal Handzus fired home the game-winning power play goal.
At the Hartwall Arena, hosts Finland left it late against the United States as Joensuu scored twice to set up a semi-final against Russia.
The game came to life when Joensuu scored his first in the 14th minute of the second period. The US hit back almost immediately through Anaheim Ducks centre Kyle Palmieri and Bobby Ryan then fired home a rebound to put them in front.
The Finns got back on level terms when Valtteri Filppula's shot was deflected in off the skate of Mikko Koivu.
Joensuu then sent the home crowd into ecstasy when he fired home Petri Kontola's feed from behind the goal with seconds left.
Sweden conceded a goal with just 29 seconds left in the game against the Czech Republic to end their hopes of qualifying for the semis.
The Swedes scored early in the first period and had plenty of possession, but the Czechs went 3-1 up in the second as the hosts struggled to convert their chances into goals.
A 90-second burst between the second and third periods put Sweden back on level terms.
Henrik Zetterberg reduced the deficit with 45 seconds left in the second, before Jonathan Ericsson equalised in the first minute of the third.
The Swedes looked the more likely of the two teams to win in regulation time, but their wasteful touch in front of goal was to cost them.
Czech forward Milan Michalek had a chance with 29 seconds left, stealing the puck and dribbling in from the right before firing high into the net.
Having gone unbeaten through the group stage, Russia faced Norway in Stockholm and fired in three goals in the final period to take the game 5-2.
The action now moves to Helsinki for the semi-finals on Saturday, when Finland take on Russia and Slovakia face the Czech Republic.