win (something) by a whisker
To succeed or defeat someone in something by only a very narrow margin. Making huge gains during the final lap, the underdog rookie managed to overtake the reigning champion and win the race by a whisker. We only won by a whisker, but at least we got the conviction we were looking for.