Japan-based Yamauchi had to reel in Kastor after the 2004 Olympic marathon bronze-medallist and 2006 London Marathon winner had built up a 200-metre lead with only two miles remaining.
Kastor was eighth at the 30km marker, sixth at the 35th and fourth at 40, easily passing the fading Ethiopian Elfenish Alemu with around a kilometer remaining in the 42.2-kilometer (26.2-mile) race to claim a surprise medal.