Karami told parliament in Beirut on Monday: "Out of concern that the government does not become an obstacle to the good of the country, I announce the resignation of the government I had the honour to lead."
Karami's resignation, which was accepted by Lebanese President Emile Lahud, followed massive public protests in the wake of former premier Rafiq al-Hariri's assassination on 14 February.
The announcement was greeted with loud applause in the national assembly, where the opposition was seeking a vote of no confidence to bring down the government.
Nevertheless, opposition figures continued calling for popular protests to continue until Syrian troops leave the country.
"The battle is long, and this is the first step, this is the battle for freedom, sovereignty and independence," opposition MP Ghattas Khuri said.
Tens of thousands of demonstrators who were gathered at the nearby Martyrs Square, amid a sea of red and white Lebanese flags, broke into singing the national anthem on hearing the news.
Speaking to Aljazeera, key opposition leader Walid Jumblatt said he was pleased by the decision.
"We want to purge the Lebanese [security] apparatus that took part in planning for the attempted assassination of Marwan Hamada and the assassination of al-Hariri," he said.
Jumblatt says the opposition is
not looking to defeat Syria
"The most urgent priority for the new government is the implementation of the Taif Accord. We are not seeking to defeat Syria in Lebanon. Never. We seek an honourable withdrawal for the Syrian army from Lebanon based on the Taif Accord.
"We stick to relations of friendship and brotherhood with Syria that bound us in the past and will continue to bind us in the future," Jumblatt said.
In a related development, one person was killed on Monday when Karami supporters rioted in his hometown in northern Lebanon shortly after he announced his government's resignation, witnesses and hospital sources said.
The witnesses said scores of armed supporters attacked the houses of at least two opposition parliamentarians in Tripoli, firing assault rifles into the air, smashing cars and setting tyres on fire in the streets.
Lahud (L) accepted Prime Minister
Hospital sources said a 22-year-old supporter of the pro-Syrian prime minister was shot dead during the rioting. It was not immediately clear who shot him.
Lebanese troops were restoring calm and had cordoned off
parts of the city, the witnesses said.
Earlier, Lebanon's parliament opened a session to vote on a no-confidence motion over al-Hariri's assassination after protesters defied a ban to demonstrate against Syrian troops.
Banks, schools and businesses closed on Monday, following an opposition call for a general strike to coincide with the debate.
Protesters defied a government
ban on gatherings
Parliamentary sources had said with a clear majority of pro-Syrian deputies in the 128-member chamber, Karami's government was set to win the no-confidence vote.
And tens of thousands of demonstrators - estimates varied from 20,000 to 50,000 - continued a sit-in at Martyrs Square in the heart of Beirut despite a ban on protests that came into effect at 5am (0300 GMT).
The ban was announced on Sunday by Lebanese Interior Minister Sulayman Franjiyah.
Aljazeera's correspondent in Lebanon, Abbas Nasir, said the Lebanese army and security forces closed all roads leading to the site, a move that opposition sources told Aljazeera blocked thousands of people from getting to the demonstrations.