OSLO — Sylvi Listhaug’s anti-immigration views and sharp comments have made her one of Norway’s most polarizing political figures, but it was a single, incendiary Facebook post that has threatened to bring down the government and led to her resignation as justice minister on Tuesday.

Ms. Listhaug and her right-wing Progress Party, which is a junior partner in a fragile coalition, supported a bill that would have allowed the government to strip Norwegian citizenship from those suspected of joining terrorist or foreign militant groups, without a court hearing. After the bill was defeated earlier this month, she lashed out online.

In a Facebook post, which she has since taken down, she said the center-left Labor Party “believes the terrorists’ rights are more important than the nation’s security,” and attached a photo of two veiled and gun-toting fighters from the Shabab militant group in Somalia, thousands of miles away.

That hit a nerve in a country with still-raw memories of its worst terrorist attack in modern times, in which Labor members were the targets. In 2011, a far-right, anti-Islam extremist, Anders Behring Breivik, detonated a bomb outside a building housing offices of the government, then led by Labor, killing eight people, and then went to a Labor youth camp on Utoya island, where he shot dead 69 people, most of them teenagers.