JUBA (Reuters) - The last Japanese troops withdrew from a U.N. peacekeeping mission in South Sudan on Thursday, marking the end of a controversial push by the Japanese prime minister to expand his military’s overseas role.

Slideshow ( 5 images )

The 40 men and women, all that remained of Japan’s 350-strong military contingent, left from South Sudan’s capital of Juba, where they have been based for the past five years as they helped build infrastructure in the war-torn country.

“I would like show my great appreciation to the Japanese Self Defense Forces,” said David Shearer, the chief of the U.N. Mission in South Sudan in a statement on Thursday.

“Your work has consistently provided services that are essential for UNMISS to carry out its mandated tasks, including the protection of civilians and assisting in delivering humanitarian aid.”

Oil-rich South Sudan has been ravaged by civil war since 2013, when President Salva Kiir, an ethnic Dinka, fired his deputy Riek Machar, an ethnic Nuer.

The withdrawal will ease political pressure on Japanese Prime Minister Shinzo Abe, who had promised in March to bring them home and vowed to resign if any troops were killed.

Violence in South Sudan has worsened after an internationally backed peace deal failed last year, creating Africa’s largest refugee crisis since the 1994 Rwandan genocide.

Parts of the country have plunged into famine and the fighting since has increasingly fractured along ethnic lines, leading the U.N. to warn of the risk of genocide.

Japan’s post World War Two constitution prevents it from participating in active conflicts. But since November, the contingent was allowed to mount rescue missions and escort U.N. staff and charity workers, a move that stoked controversy in Japan.

The expanded role was in line with a 2015 security law pushed by Abe that expanded the overseas role of the Japanese military. Critics said the change weakened Japan’s war-renouncing constitution.