MPs have overwhelmingly backed keeping UK troops in Afghanistan, in the first vote they have held on the issue.
There have been several statements and debates since the invasion took place almost nine years ago, but a motion has not previously been put to MPs.
The vote, on the question that “this House supports the continued deployment of UK armed forces in Afghanistan”, passed by a majority of 296.
Some 334 UK troops have died and around 10,000 are serving in the war.
The decision to join the US-led invasion was taken without a parliamentary vote, unlike the invasion of Iraq in 2003.
It was backed by the leaderships of all three main parties.
In June, Prime Minister David Cameron said he wanted UK troops out of Afghanistan within five years, but added he preferred not to “deal in too strict timetables”.
The Commons motion on troops in Afghanistan was tabled by the newly established Backbench Business Committee, which lays down the agenda for debate time not taken up by the government.
During the debate Labour’s Paul Flynn, who represents Newport West, said: “The rate at which British soldiers are being killed in Afghanistan is now four times that of our US counterparts.
“The whole of the operation is continuing and there isn’t any possible outcome that is going to be just, that is going to be honourable.”
He told MPs: “We have turned so many corners we have been round the block half a dozen times in Afghanistan. We are still in hell and it is still getting worse.”
Conservative Bob Stewart, who was a UN commander in Bosnia in 1992, praised the bravery of soldiers, saying many did not understand the “nuances” of politicians and the public saying they supported them but not the war.
He added: “We now have a situation where we have an increase of soldiers on the ground… and actually the principles of counter-insurgency are beginning to work and they are protecting the people. The key to this is whether the Afghan people can feel protected, safe and can live a decent life.
“But the fact of the matter is we have a real problem. We have a military aim which is probably to make sure that Afghanistan never threatens us again. We have a political aim… which is we want Afghanistan to have a decent lifestyle, taking part in the international community… and therefore not threaten us.
“It is a very difficult job our troops are doing.”
The government insists the Afghanistan mission is essential to ensuring the UK’s security, by hampering the growth of terrorist organisations in the region.
There have been numerous ministerial statements and general debates about the war, since it started in November 2001, without going to a vote.
The motion was passed by 310 votes to 14.