The no-confidence motion, which targeted Swedish Justice Minister Morgan Johansson, failed by just one vote.
Sweden's government has narrowly survived a vote of confidence in parliament amid surging crime in the country.
The vote of confidence in justice minister Morgan Johansson took place as the country aims to join the NATO military alliance, despite strong opposition from Turkey.
Prime Minister Magdalena Andersson had said that she would resign if her Social Democrat minority government lost the confidence vote.
The decisive move that avoided a major political crisis came from Amineh Kakabaveh, an independent and pro-Kurdish Iranian-born lawmaker.
Kakabaveh -- a vocal critic of Turkish President Recep Tayyip Erdogan -- abstained from voting to leave just 174 votes against Johansson.
In Tuesday’s ballot in Sweden’s 349-seat parliament, the right-leaning opposition needed a majority of 175 to topple the government and therefore fell just one vote short. There were 97 votes in favour of the Swedish justice minister, as well as 70 abstentions and eight absentees.
Turkey — which as a NATO member has a blocking vote — has opposed the bids by Sweden and neighbouring Finland amid Russia’s invasion of Ukraine.
President Erdogan has accused the two Nordic countries of backing militant Kurdish groups like the Kurdistan Workers’ Party (PKK) -- a group listed as terrorist by the European Union and the United States.
In May, Turkey’s Ambassador to Sweden claimed that the PKK has ties to certain Swedish lawmakers, who have allegedly taken a stance against Ankara.
In recent years, Sweden has suffered a rise in organised crime activity with several gang-related shootings in the major cities of Stockholm, Goteborg and Malmo.
Last week, the right-wing populist Sweden Democrats had called for the no-confidence vote, claiming Johansson had allowed “Sweden to become a gangster country.”
But Kakabaveh said that the justice minister deserved to stay in office and had succeeded in combating violence against women and so-called honour killings.
“I know that Morgan Johansson is a politician who cares about the rule of law, I do not trust the opposition,” she said before Tuesday’s vote.
The independent MP had initially threatened to vote against the justice minister over Sweden's negotiations with Turkey over NATO membership.
In November, Kakabaveh’s vote had allowed Andersson to become Sweden's first female prime minister.
Sweden is set to hold its next general election on September 11.