Opposition-backed Takeharu Yamanaka won the Yokohama mayoral election on Sunday, defeating a ruling Liberal Democratic Party candidate in a blow to Japanese Prime Minister Yoshihide Suga.

The loss by Hachiro Okonogi, a former chairman of the National Public Safety Commission, comes as Suga suffers from falling public support as he faces competition to remain LDP leader and a general election in the coming months.

Yokohama is the capital of Kanagawa Prefecture, the second-most populous city in the country after Tokyo and home to the constituency of Suga's seat in the House of Representatives.

Opposition-backed former Yokohama City University professor Takeharu Yamanaka celebrates after being assured of victory in the Yokohama mayoral election on Aug. 22, 2021, in the city near Tokyo. (Kyodo) ==Kyodo

The 48-year-old Yamanaka, a former professor at Yokohama City University who has no prior experience in public office, ran with the support of the main opposition Constitutional Democratic Party of Japan as well as the Japanese Communist Party and the Social Democratic Party.

The data scientist, whose work includes analyzing vaccine efficacy on coronavirus variants, has criticized the government for ignoring calls from infectious disease experts to take stronger measures to curb the spread of COVID-19.

Japan is experiencing its largest wave of infections yet and dissatisfaction with the prime minister's handling of the pandemic is only growing, with a recent nationwide survey by Kyodo showing support for his Cabinet at a record-low 31.8 percent.

Turnout among Yokohama's more than 3 million eligible voters was 49.05 percent, up from 37.21 percent in the previous mayoral election in 2017.

Besides serving as a gauge for Suga's popularity, the ballot served as a referendum of sorts on the city's bid to host a casino after Japan legalized their operation as part of so-called integrated resorts in 2018.

Incumbent Mayor Fumiko Hayashi, 75, who has held the job since 2009 but failed to secure a fourth term, had looked to push ahead with the plan as a way of creating jobs and boosting Yokohama's economy.

Hachiro Okonogi, a Liberal Democratic Party candidate backed by Japanese Prime Minister Yoshihide Suga, speaks after losing to opposition-backed Takeharu Yamanaka in the Yokohama mayoral election on Aug. 22, 2021. (Kyodo) ==Kyodo

Yamanaka is opposed to building the casino, arguing the designated oceanfront property would be better used to build hotels, concert halls and other facilities.

"We will issue a formal statement soon making it clear that Yokohama will not make a hosting bid," he said Sunday night, vowing to run the city in a way where "each and every citizen has their voice heard."

Okonogi, who quit the National Public Safety Commission and the lower house to run in the election, was also endorsed by Cabinet members including vaccine czar Taro Kono and Environment Minister Shinjiro Koizumi as well as members of the LDP's junior coalition partner Komeito.

But the 56-year-old only managed to secure votes from 42.7 percent of LDP supporters, according to Kyodo exit polls, a sign of growing dissatisfaction with Suga among his base. A solid chunk, 19.7 percent, went with Hayashi, who had been backed by some of the party's members in the city assembly.

"I failed to explain (my policies to the public) properly," Okonogi told reporters.

Among unaffiliated voters, Yamanaka picked up 39.5 percent of ballots, Okonogi 11.1 percent and Hayashi 9.6 percent.

The other candidates included former Kanagawa Gov. Shigefumi Matsuzawa and former Nagano Gov. Yasuo Tanaka.