Mr Rasmussen says "running for the exits" in Afghanistan is not an option
Nato chief Anders Fogh Rasmussen says he is alarmed by growing scepticism about the war in Afghanistan.
In remarks prepared for a Nato ceremony in the US, Mr Rasmussen says he is worried the public debate "has started to go in the wrong direction".
The secretary general's comments came as EU leaders urged the UN to hold a major summit on Afghanistan's future.
Increasing violence is raising concern about the future of the country eight years after the US-led invasion.
Mounting allied casualties, a rising Afghan civilian death toll and claims of widespread electoral fraud have led to growing opposition to the campaign in Western countries.
"What we need is a clear step towards transition to Afghan leadership in all areas - security, health, education, development and governance," Mr Rasmussen's remarks, released by Nato, say.
He says the fact that Nato countries are losing soldiers in the fight against the Taliban is turning public opinion against the operation.
Jonathan Marcus, BBC Diplomatic Correspondent
Anders Fogh Rasmussen's comments show the growing concern within Nato that perceived setbacks in Afghanistan are turning the public mood against the war.
It is a view borne out by the latest public opinion survey from the German Marshall Fund, released today, which shows that nearly two-thirds of Europeans (63%) are pessimistic about stabilising the situation in Afghanistan.
That is why Mr Rasmussen has stressed, like the UK, French and German leaders in their letter to the UN, the need for clear steps towards transition to Afghan leadership.
The danger is though that in signalling such a move to a transition phase - a message that they hope will signal the beginning of the end-game to Western public opinion - the same signal will be seen as a lack of commitment on the ground in Afghanistan itself.
He describes allegations of widespread fraud in last month's presidential election as "disturbing" and says there is a sense among many people in many countries "that we are not making progress fast enough".
But he adds: "We must stay in Afghanistan as long as necessary, and we will stay as long as necessary. Let no-one think that a run for the exits is an option. It is not."
Nato forces comprise about two-thirds of the more than 100,000 international troops based in Afghanistan.
Mr Rasmussen says although progress in the fight against insurgents has not been as fast as some had hoped, the situation on the ground is improving.
"The Taliban have no chance of taking power again, nor do terrorists have any safe haven in Afghanistan from which to threaten the world," he says.
"If we were to walk away... soon there will be terrorists in Afghanistan and attacking from Afghanistan, profound instability in Pakistan and in Central Asia.
"This is simply not a future we can allow to happen."
Earlier, British Prime Minister Gordon Brown, French President Nicolas Sarkozy and German Chancellor Angela Merkel pressed the UN for a summit to discuss the aftermath of the Afghan elections.
They made the plea in a letter to UN Secretary General Ban Ki-moon.
In it they said "benchmarks and timelines" should be agreed "to formulate a joint framework for our transition phase in Afghanistan... to set our expectations of ownership and the clear view to hand over responsibility step-by-step to the Afghans, wherever possible".
On Tuesday, Afghanistan's Election Complaints Commission said it had found "clear and convincing evidence of fraud" in last month's presidential election.
The UN-backed body has ordered a number of recounts and audits of votes.