President Trump and Japanese Prime Minister Shinzo Abe (left) toast during a luncheon at the United Nations in New York. (Kevin Lamarque/Reuters)

Japanese Prime Minister Shinzo Abe has one person to thank for reviving his political fortunes, and it's a surprising person: Kim Jong Un.

Just two months ago, Abe was mired in scandal and his poll ratings were falling so precipitously that analysts were ready to write the 62-year-old's political obituary. Then the North Korean leader started firing missiles over Japan and suddenly the hardline Abe was looking like just the prime minister Japan needed again.

"Kim Jong Un is doing him a great favor," said Jeff Kingston, director of Asia studies at Temple University's campus in Japan. "During crises like this, there is a rally around the flag and that helps the LDP, which is seen as strong on security," he said, referring to Abe's conservative Liberal Democratic Party.

Abe is expected to announce Monday that he is dissolving the lower house of the Diet, or parliament, and calling a snap election for Oct. 22, 14 months ahead of schedule.

During the "lost decades" since Japan's bubble burst, elections here have tended to revolve around the economy. Until now, Abe's focus has been no exception to this rule, with his concept of "Abenomics" to boost consumption and growth.

Some analysts, including Kingston, had seen this as part of a strategy for Abe to win widespread public approval and therefore the mandate to press ahead with what he really wanted to do: revise the American-written post-war constitution to allow Japan to return to normal military footing after seven decades of imposed pacifism.

That has been controversial as most Japanese thought that the constitution, particularly the war-renouncing Article 9, had served them well. Other changes in security legislation here, such as the 2015 "re-interpretation" that allowed Japan to come to the defense of the United States, had sparked protests of a size not usually seen in Japan.

But now, the threat of North Korean missiles and the relative proximity to huge nuclear explosions is making many Japanese think again.

In the space of three weeks, North Korea fired two intermediate-range ballistic missiles over the northern Japanese island of Hokkaido and into the Pacific Ocean, an apparent test of technology aimed at reaching the mainland United States. Then, earlier this month, North Korea detonated what appeared to be a hydrogen bomb that was as many as 17 times the size of the American atomic weapon that destroyed the Japanese city of Hiroshima in 1945.

A new poll found that 85 percent of respondents said they felt threated by North Korea and 68 percent said they wanted Japan to beef up its defenses against ballistic missiles. Notably, more than half (54 percent) said they wanted Japan to have the capability to launch an offensive strike, according to the poll from the conservative newspaper Sankei and Fuji television network.

A growing number of influential lawmakers in the LDP, including the current defense minister, have been calling for Japan to be allowed to have pre-emptive strike capabilities, not just the defensive ones as laid out in the existing constitution.

Earlier this week, Japan deployed a Patriot Advanced Capability-3 missile-defense system to Hokkaido, although the system has a range of only 12 miles and the most recent North Korean missile reached a height of 480 miles. Abe's government also wants to deploy the Aegis Ashore land-based anti-missile system and is in talks with the Trump administration about this.

Helpfully, the Yomiuri newspaper, which is staunchly supportive of Abe, reported that President Trump had praised the Japanese prime minister's "strength" when the two had lunch in New York this week.

Abe has seized on this opportunity to call the election, said Atsushi Kinoshita, a political analyst who served as a lawmaker for the main opposition Democratic party.

"With North Korean missiles flying over Japan and local governments conducting evacuation drills, of course people feel a sense of crisis," he said. "Prime Minister Abe is betting that Japanese citizens will agree with his position on reinforcing Japan's military."

This is quite a turn-around from July, when Abe was being pummeled with allegations of cronyism and his approval ratings plummeted from around 60 percent to below 30 percent. At the same time, the LDP suffered a crushing defeat in the Tokyo Metropolitan Assembly election.

These factors had analysts wondering whether he could even survive an LDP leadership election next year.

But the scandals have faded into the background over the summer, and the prime minister reshuffled his cabinet. His ratings are back up around the 50 percent mark in the latest Yomiuri poll.

That gave Abe an opening, said Harumi Arima, a political commentator on Nippon TV who calls this an "election for survival."

"Abe's approval rate is now picking up and the Democratic Party is coming apart," Arima said, while the political party formed by Tokyo governor Yuriko Koike does not yet have a national presence. "If Abe waited until next year, there would be less and less opportunity to find a good time for a snap election and he might have no choice but to dissolve the lower house at a time when his approval rating is low."

Calling the election now also has the added benefit of dissolving the Diet before it can question Abe about the corruption scandals that plagued him before the summer break. The lower house is due to go into an extraordinary session, where Abe could be questioned, on Sept. 28, the day that the prime minister is now expected to dissolve the parliament.

The left-leaning Asahi Shimbun, which is generally critical of Abe, said the prime minister was calling the snap election to "serve nothing but his own interest" so that he can "weasel out" of being questioned on the scandals.

"Abe will go down in history for setting a dishonorable precedent as a prime minister who took the liberty to 'own' the right to dissolve the Lower House for no other reason than to protect himself," the newspaper wrote in an editorial Thursday.

Kinoshita agreed, calling the decision to call a snap election "a very selfish act" that went against the wishes of the Japanese people.

The big question now is not whether Abe will call the election, but whether he will maintain his two-thirds supermajority in the lower house, a threshold that is crucial if he is to proceed with trying to revise the constitution.

"He may win big but he may also lose his super majority in the lower house," said Kingston. "If the voters give Abe a nasty surprise, it might bring out the long knives in the party. But the chances of that happening are not huge."

Why Japan's first lady was probably not snubbing President Trump

The White House keeps mixing up the names of Asian countries and their leaders' titles

What is North Korea trying to hit?