Brewer's goal came during a four-on-three situation as Daniel Kunce was called for slashing late in the third period. Canada had not won an overtime game in the Olympics or World Championships since Paul Kariya tallied to beat the Czech Republic in the quarterfinals of the 1994 Olympics.
Canada had a power play when Ryan Smyth, Brewer's teammate on the Edmonton Oilers, opened the scoring 3:04 into the game. Daniel Briere tipped defenseman Cory Cross' shot past goaltender Robert Muller with 7:17 left in the second period to double Canada's lead.
Sean Burke made 28 saves for Canada, which will face the Czech Republic in the semifinals on Friday.
Hejduk set up Jan Hlavac's goal to make it 1-0 with 3:34 remaining in the opening period. Hejduk, who led the NHL with 50 goals for the Colorado Aavalanche this season, scored on the power play off a pass from defenseman Tomas Kaberle to make it 2-0 at 9:01 of the second.
Slovakia used a 3-1 triumph over Switzerland to advance to a meeting with Sweden, which rallied from a four-goal deficit for a stunning 6-5 victory over Finland.
Miroslav Satan scored twice and Jan Lasak made 30 saves for Slovakia.
Jorgen Jonsson started the comeback 80 seconds later and Peter Forsberg and Jonas Hoglund scored before the end of the period to make it 5-4.
Forsberg tied it 8:22 into the third and P.J. Axelsson's power-play tally put Sweden ahead with 4:54 remaining.
"I've never seen anything like this," Swedish defenseman Mattias Norstrom said. "When we were down four goals, things seemed pretty hopeless for us."
Finnish coach Hannu Aravirta called it "a nightmare finish to the tournament for us."
Notable deaths of 2014 [PHOTOS]