TOKYO, Sept 27 (Reuters) - Veteran lawmaker Shigeru Ishiba was set on Friday to become Japan's next prime minister after winning a closely fought contest in his fifth and final attempt to lead the ruling Liberal Democratic Party.

Ishiba prevailed over hardline nationalist Sanae Takaichi in a run-off vote in what was seen as one of the most unpredictable leadership elections in decades with a record nine candidates in the field.

The leader of the LDP, which has ruled Japan for almost all of the post-war era, is essentially assured of becoming Japan's premier because of its majority in parliament.

The scramble to replace current premier Fumio Kishida was sparked in August when he announced his intention to step down over a series of scandals that plunged the Liberal Democratic Party's (LDP) ratings to record lows.

Ishiba must quell anger at home over rising living costs and navigate a volatile security environment in East Asia fuelled by an increasingly assertive China and nuclear-armed North Korea.

In brief comments made to lawmakers before the run-off, Ishiba called for a fairer and kinder Japan and tears welled in his eyes after the final results were read out.

Ishiba has courted controversy with his peers for going against the grain and challenging previous leaders, and has failed in four previous leadership bids. He has said he will not run again after this contest.

He supports some socially progressive policies like changing the law to allow married couples to use separate surnames, a move opposed by Takaichi and other more conservative LDP lawmakers.

Photo from Reuters