An investigation into alleged war crimes by the US and others in the Afghanistan war can go ahead, the International Criminal Court has ruled.

The US invaded Afghanistan in 2001 in order to dismantle al-Qaeda and deny it a safe base by removing the Taliban from power. About 13,000 US troops are still based in the country.

The global court upheld an appeal by prosecutors on Thursday, meaning that the investigation into alleged war crimes by the US military, the Taliban and Afghan forces has now been authorised.

This follows the rejection of a request by prosecutor Fatou Bensouda in April last year to open an inquiry, despite pretrial judges acknowledging that widespread crimes had taken place.

Both Afghanistan, which is an ICC member country, and the US, which does not recognise the court, have strongly objected to the investigation.

Afghanistan conflict: When War Comes Home – photo exhibition Show all 10 1 /10 Afghanistan conflict: When War Comes Home – photo exhibition Afghanistan conflict: When War Comes Home – photo exhibition Zakhem | Wounds: When War Comes Home Walas Bibi, 10 (left), was wounded in her arm and stomach by two bullets during a shoot-out between the army and the Taliban. Zubaida, 8 (right), was wounded in her legs by shrapnel from a bomb as she went to fetch water Giulio Piscitelli Afghanistan conflict: When War Comes Home – photo exhibition Zakhem | Wounds: When War Comes Home Jawidullah Muhamad Khan, 12, from Ghazni, wounded during a bombing near his home as he came back from school with some friends. He lost four fingers and was injured in his leg in multiple places during the raid, which hit everyone in the area Giulio Piscitelli Afghanistan conflict: When War Comes Home – photo exhibition Zakhem | Wounds: When War Comes Home Ambulance transport for two young wounded men Giulio Piscitelli Afghanistan conflict: When War Comes Home – photo exhibition Zakhem | Wounds: When War Comes Home Noorahad, 12, from the Marjah area, hit by a bullet while he was simply sleeping in his bed at home Giulio Piscitelli Afghanistan conflict: When War Comes Home – photo exhibition Zakhem | Wounds: When War Comes Home Anahita, 18, hit by a bullet while her husband was cleaning his gun. She risked losing her right leg, as her thigh bone was broken Giulio Piscitelli Afghanistan conflict: When War Comes Home – photo exhibition Zakhem | Wounds: When War Comes Home A rehabilitation session for Mujahid, 10, wounded in a shoot-out between the Taliban and Afghan army near his home in the Nad Ali area Giulio Piscitelli Afghanistan conflict: When War Comes Home – photo exhibition Zakhem | Wounds: When War Comes Home Mafton, 5, wounded in a clash between the Afghan army and Taliban militias in Tagab district, in Kapisa province. When a rocket exploded, he lost his left eye and his chest was wounded all over Giulio Piscitelli Afghanistan conflict: When War Comes Home – photo exhibition Zakhem | Wounds: When War Comes Home A father speaks with first aid staff looking after his son, wounded by an explosive device Giulio Piscitelli Afghanistan conflict: When War Comes Home – photo exhibition Zakhem | Wounds: When War Comes Home Nurses in Kabul take care of Somaya, 1, who had surgery on her right foot, wounded by shrapnel from an explosive device Giulio Piscitelli Afghanistan conflict: When War Comes Home – photo exhibition Zakhem | Wounds: When War Comes Home A patient left wounded by the explosion of a car bomb is treated in Kabul Giulio Piscitelli

As such, it remains unclear whether any suspects who are later charged will appear at the court in The Hague.

The presiding judge, Piotr Hofmanski, said: “The Appeals Chamber considers it appropriate to amend the appealed decision to the effect that the prosecutor is authorised to commence an investigation into alleged crimes committed on the territory of Afghanistan since 1 May 2003, as well as other alleged crimes that have a nexus to the armed conflict in Afghanistan.”

Ms Bensouda, a Gambian lawyer, asked judges to allow a far-reaching investigation in November 2017, following a preliminary probe into the conflict in Afghanistan.

She said there is information showing that members of the US military and intelligence agencies “committed acts of torture, cruel treatment, outrages upon personal dignity, rape and sexual violence” against detainees in Afghanistan and other locations, largely between 2003 and 2004.

The prosecutor also said that other crimes had been committed by the Taliban and other insurgent groups, including the killing of 17,000 Afghan civilians since 2009 – of which 7,000 were targeted killings.

She added that Afghan security forces are thought to have tortured prisoners at government detention centres.

In a hearing in December last year, the Afghan government said it was opposed to the investigation and that it had set up its own probe.

As the ICC is the court of last resort, it only brings cases if national jurisdictions are either unable or unwilling to bring a genuine prosecution.

The US has also spoken out against the investigation. Jay Sekulow, a lawyer for Donald Trump, appearing on behalf of the American Centre for Law and Justice, told appeals judges in December that the US would not change its position.

Mr Sekulow said: ”It is not in the interests of justice to waste the court’s resources while ignoring the reality of principled non-cooperation.”

Commenting on Thursday’s ruling, Preetha Gopalan, deputy head of UK litigation at the legal charity Reprieve, told The Independent: “This decision is welcome news to everyone who believes that the perpetrators of war crimes should not enjoy impunity, no matter how powerful they are.”

The ICC’s decision comes just days after a peace deal was signed by the US and the Taliban.

On Wednesday, the US carried out its first air raid against the Taliban since signing the deal on Saturday in Doha, Qatar.