WARSAW—A few days before Christmas, Poland’s parliament quickly convened to put an end to an untenable arrangement: Hundreds of North Koreans working in Poland under slave-like conditions to earn money for their nuclear-armed pariah state.

North Koreans had been spotted farming tomatoes outside Warsaw and welding for Polish state-owned companies. A Norwegian magazine even reported a paper trail showing them repairing a NATO warship in a Polish shipyard. Their presence took on special urgency as 2017 closed because Poland was...