Listhaug had been poised to lose a vote of confidence in parliament on Tuesday over her Facebook posts that could have toppled the government. Her decision to resign on Tuesday morning defused Norway’s worst political crisis in years.

“The choice [to resign] was mine alone, and I’ve done what I believe was right,” Listhaug told a news conference, adding that she felt the process had been a witch-hunt against her.

Listhaug, of the Progress party, provoked outrage this month when she accused the opposition Labour party of putting “terrorists’ rights” before national security, a particularly sensitive topic for Labour which was in power in 2011 when the far-right militant Anders Behring Breivik carried out a mass shooting.

Listhaug made her comments after Labour and the Christian Democrats helped defeat a bill allowing the state the right, without judicial review, to strip individuals of Norwegian citizenship if they were suspected of terrorism or of joining foreign militant groups.

She apologised in parliament last week for causing a political storm. Opposition parties, however, said her gesture was not sincere enough and that she should resign.

The opposition Christian Democrats said on Monday they would join five centre-left parties in backing a no-confidence motion, securing a majority in favour of ousting Listhaug.

The vote in parliament had been scheduled to take place later on Tuesday.

The Conservative prime minister, Erna Solberg, faced the choice of letting Listhaug go, weakening the cabinet and risking a defection by her Progress party allies, or to get the whole government to resign.

Listhaug “told me late last night that she wanted to resign,” Solberg told a news conference, adding that Listhaug could potentially make a comeback in the cabinet at some point.

“The important thing for me is that the Progress party remains in government,” Listhaug said.

She lashed out at Labour and the Christian Democrats, arguing they were not sufficiently tolerant of free speech when they sought her dismissal.

“The national debate has been turned into something of a kindergarten dispute,” Listhaug said. “I don’t want to change. I see this as an attempt to gag the debate. I will continue to pursue the fight from parliament.”

Norway does not allow snap elections, and while Solberg might have been able to form a new government, the task could also have fallen to the Labour leader, Jonas Gahr Støre.

“My goal here is to keep Støre out of the prime minister’s office,” Listhaug said.