SEOUL — Kim Jong Un's pursuit of nuclear weapons, incendiary rhetoric and odd appearance often cast the North Korean leader as an erratic, even deranged dictator.

Yet analysts and South Korean government officials who track North Korea closely describe Kim as a clever and rational, if brutal, figure who has solidified control over his country since assuming power in 2011.

Developing nuclear weapons that threaten the United States is his insurance policy against being overthrown by a U.S.-led coalition, said Joo Seong-ha, a defector who was imprisoned in North Korea before escaping to South Korea.

A nuclear weapons program is “the most powerful bargaining chip that North Korea has,” said Joo.

Kim, the third generation of his family to rule the isolated country, is mindful that Iraqi dictator Saddam Hussein was ousted by a U.S.-led coalition in 2003, said Jenny Town, assistant director of the U.S.-Korea Institute at Johns Hopkins School of Advanced International Studies. Saddam did not have nuclear weapons or any other weapons of mass destruction, as President George W. Bush claimed as justification for invading Iraq.

“The idea that Kim Jong Un’s decisions, particularly about his nuclear weapons program, are irrational is a myth,” Town said. “The caricature, cartoonish image of him is easy for people to believe.”

Either way, he is the most dangerous security threat President Trump faces. North Korea has launched more than a dozen test missiles since February and may be within a year or two of being able to place a nuclear warhead on a missile capable of reaching cities in the United States.

"We are at a point in time where choices will have to be made one way or the other," Gen. Mark Milley, the Army chief of staff, said recently. "None of them are good.”

Little was known about Kim when he came to power in his 20s. (His birth year is believed to be in 1983 or 1984.)

He was schooled for a time in Switzerland and was an avid basketball enthusiast who would play pickup games with his security detail, according to North Korea Leadership Watch, an organization that tracks the secretive government. He was drinking whiskey and smoking cigarettes by age 15, according to the organization’s website.

He only emerged as a public figure a year before the death of his father, Kim Jong Il, and had to move quickly to establish control over the country his father had ruled for 17 years. He proved ruthless in knocking off rivals and consolidating power.

“There were a lot of expectations and a lot of doubts about who he was,” Town said. “His early moves were geared toward trying to establish his own power base.”

Kim ordered his uncle, Jang Song Thaek, executed about a year after coming into power, according to the South Korean intelligence service.

More recently, he is suspected by South Korea's government of ordering the killing of his exiled half brother, Kim Jong Nam, a potential rival who was poisoned with a toxic nerve agent in Malaysia in February. Kim also executed five senior government officials with anti-aircraft guns, according to the government here.

In another sign of the his cruelty, the regime imprisoned Otto Warmbier, a visiting U.S. college student, allegedly for stealing a propaganda poster in a hotel in the North Korean capital Pyongyang. He served 18 months behind bars before being returned to the United States in a comatose state. He died a week later.

Three Americans are still held by North Korea, which also operates brutal forced labor camps where citizens are imprisoned.

While solidifying his power, Kim has liberalized the economy and broadened his support in a country plagued by a deadly famine in the 1990s.

Despite international sanctions aimed at squeezing the regime into ending its nuclear weapons program, new buildings are going up in Pyongyang, more cars are on the streets, and luxury goods are available in some stores. Apartments are selling for more than $100,000, a dramatic price increase for an impoverished country, said Moon Chung-in, an adviser to South Korean President Moon Jae-in.

The economy grew 3.9% last year over the previous year, the largest increase since 1999, according to South Korea's central bank. About 90% of North Korea's trade is with China, but North Korea has also engaged in illicit weapons sales in Africa and elsewhere in defiance of sanctions, according to the United Nations.

Shops in Pyongyang now carry flat screen televisions and luxury brands. Still, it’s nothing like the prosperity 120 miles to the south in Seoul, the bustling, economically vibrant capital of South Korea. The average annual income in North Korea is $1,300, compared to $28,000 in South Korea and $56,000 in the United States.

Still, the income figure represents a major improvement for North Korea, where citizens have long lived with economic deprivation under a state-controlled system.

Kim hasn’t removed regulations that prohibit free markets, but his government has looked the other way in many cases, allowing small businesses to operate independently and a small property market to emerge.

Kim's father experimented with liberalizing the economy, but usually backtracked, said Kent Boydston, an analyst at the Peterson Institute for International Economics. His son seems more committed to at least modest reforms.

The changes have helped make him more popular, particularly among younger North Koreans, Moon Chung-in said.

“North Korea is very, very stable,” he said. “Kim Jong Un has consolidated power fully.”

This story was based on reporting conducted on a trip to South Korea sponsored by the East-West Center, the Korea Press Foundation and the Pacific Century Institute.

Read more:

North Korea:Tillerson said U.S. seeks dialogue with North if it abandons nuclear program

Missile threat:North Korea missile launch gives already nervous fliers more to worry about