As battles raged in Syria's second city Aleppo between rebel fighters and government forces using war planes and artillery, UN Secretary General Ban Ki-moon announced in New York that Annan had said he would go at the end of the month.
"Kofi Annan deserves our profound admiration for the selfless way in which he has put his formidable skills and prestige to this most difficult and potentially thankless of assignments," Ban said. Talks were under way to find a successor.
Annan's mission, centred on an April ceasefire that never took hold, has looked irrelevant as fighting has intensified in Damascus, Aleppo and elsewhere.
Annan blamed "finger-pointing and name-calling" at the UN Security Council for his decision to quit but suggested his successor may have better luck.
"The world is full of crazy people like me. So don't be surprised if Secretary General Ban Ki-moon can find someone who can do a better job than me," Annan said.
Syria expressed regret that Annan was going. Russia, a key ally of Damascus, also said it regretted the decision, while Britain, which wants Assad to resign, said it showed that the mediation process was not working.
The White House said Annan's decision to quit had highlighted Assad's failure to meet his promise to abide by the ceasefire plan, and added that it continued to believe that "Assad must go".
In Syria, the fight for Aleppo, the latest battlefield, intensified. Rebels turned the gun of a captured tank against government forces, shelling a military airbase north of the city.
Assad's troops meanwhile bombarded the strategic Salaheddine district in Aleppo itself with tank and artillery fire supported by combat aircraft while rebels tried to consolidate their hold on areas they have seized.
In the capital Damascus, troops overran a suburb on Wednesday and killed at least 35 people, mostly unarmed civilians, residents and activist organisations said.
The fighting for Syria's two biggest cities highlights the country's rapid slide into full-scale civil war 17 months on from the peaceful street protests that marked the start of the anti-Assad uprising.
World powers have watched with mounting concern as diplomatic efforts, including Annan's mediation effort, have faltered and violence that has already claimed an estimated 18,000 lives worsens.
About 60 people were killed in Syria on Thursday, 43 of them civilians, according to the opposition Syrian Observatory for Human Rights.
The rebels' morale was boosted when they turned a government tank's gun on the Menakh airfield 35 km north of Aleppo - a possible staging post for army reinforcements and a base for war planes and helicopter gunships.
"We hit the airport using a tank that we captured from the Assad army. We attacked the airport a few times but we have decided to retreat at this time," a rebel fighter named Abu Ali told Reuters.
Other rebel sources said they had pulled back after coming under fire from MiG warplanes from the airport.
The lightly armed insurgents are battling a well-equipped army that has overwhelming superiority on paper. But the rebels have managed to capture some tanks and heavy weapons and their ranks are swelled by army defectors.
Rebel fighters said they had used improvised explosives in an attack on the Nejrab international airport on the outskirts of Aleppo but there were no reports of serious damage.
Reuters correspondents heard heavy weapons fire on Thursday morning from Salaheddine in southwest Aleppo, a gateway to the city that has been fought over for the past week.
Heavily armed government troops are trying to drive a force of a few thousand rebel fighters from the city in battle whose outcome could be a turning point in the conflict.
Although government forces have made concerted efforts to take Salaheddine, a full-out assault on the city as a whole has yet to take place.
Mobile phone connections have been cut since Wednesday evening, leading to speculation among residents that an increase in military action might be imminent.
The rebels are consolidating areas they control in Aleppo, attacking police posts and minor military installations with some success. They claim to have seized three police stations this week.
Aleppo had long stayed aloof from the uprising but many of its 2.5 million residents are now caught up in battle zones, facing shortages of food, fuel, water and cooking gas. Thousands have fled and hospitals and makeshift clinics can barely cope with casualties after more than a week of combat.
The U.N. Food and Agriculture Organisation said up to three million Syrians are likely to need food and other aid in the next 12 months because the conflict has prevented farmers from harvesting their crops.
Syria meanwhile accused Turkey of backing terrorism by opening its airports and borders to al Qaeda to carry out attacks inside Syria.
Once an ally of Syria, Turkish Prime Minister Tayyip Erdogan has called on Assad to step down and has set up refugee camps for thousands of displaced Syrians.
"The Turkish government plays a fundamental role in supporting terrorism by opening its airport and borders to host al Qaeda elements, jihadists and salafists," Syria's foreign ministry said in a statement circulated on state television.
"The Turkish government has set up on its soil military offices where Israeli, American, Qatari and Saudi intelligence agencies direct the terrorists in their war on the Syrian people," the statement said.
Damascus also accused France and the United States of sending rebels communications equipment. U.S. sources have said President Barack Obama signed a secret order authorising U.S. support for rebels seeking to depose Assad.
A Turkish foreign ministry spokesman said: "It is not the first unsupported claim coming from Syria. These speculative claims are not reflecting the truth."
In New York, the UN General Assembly was expected to vote today on a resolution drafted by Saudi Arabia, which backs the rebels.
Russia, which has consistently supported Syria at the United Nations, said it would not back the resolution because it was unbalanced and would encourage rebels to keep fighting.