TOKYO (Reuters) - Japan’s Self Defense Force will withdraw from the United Nations peacekeeping mission in South Sudan when its troops return home around the end of May, closing a controversial episode in the prime minister’s push to expand the military’s overseas role.

FILE PHOTO: United Nations Mission in South Sudan (UNMISS) peacekeepers from Japan assemble a drainage pipe at Tomping camp, where some 15,000 people who fled their homes following recent fighting are sheltered by the United Nations, in Juba January 7, 2014. REUTERS/James Akena/File Photo

The primary task of Japan’s 350-strong military contingent, based in Juba for the past five years, has been to build infrastructure in the war-torn country.

Oil-rich South Sudan has torn by civil war since 2013, when President Salva Kiir, an ethnic Dinka, fired his deputy Riek Machar, an ethnic Nuer. Fighting since has increasingly fractured the world’s youngest country along ethnic lines, leading the U.N. to warn of the risk of genocide.

“As South Sudan’s country-building is entering a new phase, we can draw a line under the activities of the self-defense forces,” Prime Minister Shinzo Abe told reporters at his residence in Tokyo on Friday.

Japan would continue providing development aid, however, he added.

The withdrawal will ease political pressure on Abe, who had vowed to resign if any troops were killed, as his support amongst voters erodes after his wife was linked to a school accused of involvement in a murky land deal.

The end of the mission will also help Defense Minister Tomomi Inada, who rejected opposition calls to resign because she refused to describe the conflict as “fighting.”

Doing so would have forced Abe’s government to evacuate the troops, because a halt to fighting in the area is a condition for the SDF to participate in U.N. peacekeeping missions.

In a move that stoked controversy in Japan, the contingent was allowed, from November, to mount rescue missions and escort U.N. staff and personnel of non-government bodies (NGO).

That was in line with a 2015 security law pushed by Abe that expanded the SDF’s overseas role, a change critics say has weakened Japan’s war-renouncing constitution.