Alfred Yego, finding hidden speed, pipped Canada's Gary Reed on the line to win the 800 metres title by the thickness of his vest.
Reed, who led from gun-to-tape, appeared to have the race tied up until he tired and his Kenyan rival snatched gold from his grasp.
Russia's Olympic champion Yuriy Borzakovskiy came third in 1min 47.39sec.
Reed, ranked fifth in the world this year, had done everything in text book style before being robbed of what would have been Canada's first gold medal since Perdita Felicien's 100m hurdles win in 2003.