Leaders of Nato's 28 states have backed a strategy to transfer leadership for the fight against the Taliban to Afghan forces by the end of 2014.
Afghanistan President Hamid Karzai was in Lisbon, where he signed a long-term security partnership with Nato.
Nato's secretary general said the Taliban would not be allowed simply to wait for foreign forces to leave, saying Nato would remain committed.
Nato would stay "as long as it takes", Anders Fogh Rasmussen said.
However, news agencies quoted US officials at the summit as saying that Washington had not yet taken a decision on ending combat by the end of 2014.
Meanwhile, Russian President Dmitry Medvedev arrived at the summit to deliver an address and to discuss Nato's invitation to join a key missile defence shield project.
'As long as it takes'
The Afghan delegation and Nato leaders held several hours of talks on Saturday morning.
In front of the world's media, President Karzai and Mr Rasmussen then signed a formal partnership that Nato says will codify its commitment to Afghanistan for years to come.
Despite agreeing to transfer military control to Afghanistan by 2014, Mr Rasmussen said this would not be a signal for the Taliban to claim victory.
"One thing must be very clear - Nato is in this for the long term," he said.
"We will not transition until our Afghan partners are ready. We will stay after transition in a supporting role.
"If the enemies of Afghanistan have the idea that they can wait it out until we leave, they have the wrong idea. We will stay as long as it takes to finish our job."
Mr Karzai said the decision to transfer military control would give every Afghan a stake in the future of their country.
He hoped that in future "Afghanistan will be [a country] contributing to world security and economy rather than one that will be a burden".
President Karzai said he had thanked Nato for the sacrifices made by its soldiers, but added: "I also informed them of the concerns of the Afghan people with regard to civilian casualties, with regard to detentions, with regard to, at times, Nato's posture."
Nato's International Security Assistance Force (Isaf) has some 130,000 soldiers based in Afghanistan, most of them from the US.
The US has not yet endorsed the decision on combat operations. One senior US official said: "The issue of changing the combat mission is an independent national decision which will be made by all 28 nations of Nato. In the case of the United States, we simply have not taken that decision yet."
Under the new Nato plan there would still be a role for Isaf troops in the country in 2015 and onwards, but that would largely be in training Afghan forces.
After the Afghan partnership signing, Nato opened its first summit with Russia since the Russia-Georgia war two years ago.
As Mr Medvedev arrived, German Chancellor Angela Merkel said: "A former military adversary is now clearly a partner."
Nato will speak with Mr Medvedev about an agreement Nato members have reached on developing and deploying defences against ballistic missile attack on their territories.
Nato hopes Russia - a long-term opponent of previous US missile defence plans - will agree to join the project.
US President Barack Obama said the agreement "responds to the threats of our times" and would benefit all Nato citizens.
"For the first time, we have agreed to develop a missile defence capability that's strong enough to cover all Nato European territory and populations, as well as the United States," he said.
The BBC's diplomatic correspondent Jonathan Marcus says that bringing Russia on board will not be easy - Moscow has rejected all previous invitations over fears its own missile force might be compromised.
The two-day Lisbon summit has been billed as one of the most important in the alliance's history, as it seeks to update its strategy and structure to face new security threats.
On Friday member states agreed a new 10-year "strategic concept", a document that defines the fundamental nature of Nato's role in the world .
The document commits Nato members "to defend one another against attack, including against new threats to the safety of our citizens", without defining a geographical limit to its theatre of operations.
The alliance would also seek to "create the conditions" for a world without nuclear weapons, but until that goal was in sight would remain a nuclear-armed organisation.
That decision will see US nuclear weapons remain in Europe despite calls from Germany and some other members for Mr Obama to pull them out.