Freivalds said that the situation had made it impossible for her to do her job.
Prime Minister Göran Persson announced Freivalds' departure a press conference at the Rosenbad government offices on Tuesday morning.
Vice prime minister Bosse Ringholm has replaced her as temporary foreign minister, said Persson.
"I have today received Laila Freivalds' letter of resignation and I have accepted it," said Göran Persson, sitting at Freivalds's side.
In recent days her position became untenable as it emerged that that she knew that a foreign ministry official contacted the internet hosting company which later closed the web site of the Sweden Democrats (Sverigedemokraternas).
Speaking to journalists at the time, Freivalds had denied prior knowledge of this. However, on Monday it became clear that she had been consulted on the matter.
Opposition leaders called for her resignation, saying that she had lost the confidence of the people. They were joined by the government's ally, the Green Party.
Laila Freivalds was at the press conference and explained her decision:
"I feel that the current situation has become impossible for me. It is damaging to the government, to the party and to the foreign ministry, and therefore I have chosen to resign," she said.
"Yesterday evening I held a press conference in Brussels on the election in Belarus and none of the journalists were interested in that issue. That was when I realised this is impossible.".
Persson said that Freivalds had been "a competent and strong foreign minister".
The prime minister denied knowing that Freivalds had spoken with her colleagues about the plans to contact Levonline. But he dismissed suggestion that he had been misled by his foreign minister:
"We clearly had crossed lines when it came to information. I've no reason at all to say that I have been misled."
"I think it's good that we can draw the line under this story," said the Green Party's spokesperson Peter Eriksson to TT.
"And it was good that Laila understood that there wasn't the confidence in her that is needed today."
Freivalds had also faced months of criticism following her handling of the tsunami catastrophe.