by a nose; photo finish
Primarily a horse racing term for a very narrow margin of victory, but can be used figuratively for any extremely close contest.
彼の馬は鼻差で優勝した。
His horse won by a nose.
選挙はまさに鼻差の勝負だった。
The election was truly a photo-finish contest.
Compound of 鼻 (nose) and 差 (difference, margin), literally 'nose difference'. The term originates from horse racing, where a nose is the smallest measurable winning margin.