Sometimes disqualifications giveth, and sometimes they taketh away.

On Friday night, in the men’s 4×100 sprint relay final, Canada’s fourth-place finish turned into a bronze medal when the American team (which had crossed the line in third place) was disqualified for an illegal exchange.

RELATED: Record broken, job done in relay
RELATED: Canada wins Olympic relay bronze

(L-R) Andre De Grasse, Brendon Rodney, Aaron Brown and Akeem Haynes.

(L-R) Andre De Grasse, Brendon Rodney, Aaron Brown and Akeem Haynes.

While it was jubilation for Athletics Canada in Rio, the ending of the final was a mirror image of Olympic heartbreak the team had suffered just four years earlier.

At London 2012, the quartet of Gavin Smellie, Oluseyi Smith, Jared Connaughton and Justyn Warner finished third in the final, believing they’d won Canada’s first medal in the event since a famous gold at Atlanta 1996.

But the Canadian team was subsequently DQed for a lane infringement, an infraction for which Connaughton immediately took responsibility and apologized.

Canadian sprinters at London 2012 before it was learned that they had been disqualified from the 4x100m.

Heartbroken Canadian sprinters at London 2012 as it was learned that they had been disqualified from the 4x100m.

Two members of that team, Smellie and Warner, would get a bit of redemption the following year at the IAAF World Championships.

The Canadians finished fourth in the 4×100 relay at Moscow 2013, but the third-place Great Britain team found themselves disqualified, moving Canada into their spot. The bronze was Canada’s first global championships medal in the event since Olympic hero Donovan Bailey anchored the team to a gold at the 1997 World Championships.

But there was to be bitter disappointment two years later at the 2015 Pan American Games, in front of the hometown crowd in Toronto.

Photo appears to show Gavin Smellie stepping on the line separating lanes seven and eight ever so slightly during men's TO2015 4x100m final. Canada crossed the finish line in Pan Am Games record time, however this singular incident was reportedly protested by three countries that befitted at Canada's expense.

Photo appears to show Gavin Smellie stepping on the line separating lanes seven and eight ever so slightly during men’s TO2015 4x100m final. Canada crossed the finish line in Pan Am Games record time, however this singular incident was reportedly protested by three countries that befitted at Canada’s expense.

That year the Canadian team, which included a rising star named Andre De Grasse, triumphantly galloped to a gold medal… until, that is, protests from their competitors eventually led to a disqualification, and the stripping of that gold.

RELATED: Why Canada was disqualified at TO2015
RELATED: DQ hands Canada relay bronze at worlds

The following month at the IAAF World Championships in Beijing, the karmic balance swung back in favour of Canada, as they once again won a bronze medal thanks to a disqualification. On that occasion, it was the Americans who were punished for an illegal exchange and bumped off the podium.

De Grasse, Aaron Brown, Brendon Rodney (all three of whom were on the Beijing 2015 team) and Akeem Haynes carried Canada’s medal hopes into the final at Rio 2016. Though De Grasse’s prior medal finishes in the 100m and 200m events gave the team high hopes, the recent history of DQs meant nothing could be taken for granted in the relay final.

A late surge by De Grasse, running the anchor leg, was enough to put Canada across the finish line in fourth place.

That would end up being massive since—as has been the case so many times in recent years—Canada’s place on (or off) the podium at a big event was ultimately decided by a DQ.