For Jong Yol-ri, the International Mathematical Olympiad in Hong Kong last year was his last chance for freedom.

If the then 18-year-old, two-time silver medallist in the ­competition waited another year, he would be too old to take part, losing his chance to travel and ­escape North Korea.

Watch: The refugee life of Jong Yol-ri in Hong Kong

But the stakes for anybody crossing the Pyongyang regime are extreme — as the assassination this month of Kim Jong-nam, half-brother of leader Kim Jong-un, clearly shows.

Defectors caught and sent back to North Korea face years of imprisonment, or even death in camps, according to a 2012 report by the Committee for Human Rights in North Korea.

But when the moment came, Jong took it. On July 17 last year, a day after the competition, Jong sneaked out of the dormitory at the Hong Kong University of ­Science and Technology, where the event had been held, and took a taxi to the airport.

Revealing previously unpublished details of Jong’s flight, a diplomatic source familiar with the case said the student had planned his defection well before he left North Korea for Hong Kong.

He told one other person about the plan – his father, a maths teacher at a middle school in the country’s south. Despite the likelihood of retribution, Jong’s father told his son to go and not to worry, giving him roughly US$200 in hard currency, the source said. Jong had glimpsed the outside world on his trips to the Olympiad in Cape Town, South Africa, in 2014 and Chiang Mai in Thailand a year later. His family’s television could also pick up weak signals from across the border showing life in South Korea.

In Hong Kong, Jong and other North Korean contestants were placed under strict surveillance. They could not use smartphones, had to relinquish their passports and were closely monitored by a team leader.

Once the competition was over, Jong, who had by then won his third silver medal in the Olympiad, was racing against time. He took a taxi to Hong Kong International Airport where he thought he could find some South Koreans. He approached staff working for a South Korean airline and told a manager that he wanted to go to South Korea, the source said.

The manager then called the South Korean consulate and Jong was told that he had to take a taxi there by himself – protocol prevents diplomats from helping citizens from any country go into a foreign embassy or consulate.

“When he walked into the consulate, the staff there were stunned by his bravery,” the source said. “They were also very worried about his parents’ safety.”

Jong spent the next two months at the consulate, living in a small room, playing computer games and using a treadmill to exercise.

“He seldom talked in the first month, but gradually got to know consulate staff,” the source said. “The consulate was busy providing around-the-clock assistance to him, but staff avoided asking questions related to his family for fear of upsetting him.”