UNITED NATIONS — The Security Council voted unanimously Thursday to end the U.N. peacekeeping mission in Haiti in mid-October after more than 20 years, sending a strong signal that the international community believes the impoverished Caribbean nation is stabilizing after successful elections.

The resolution approved by the U.N.’s most powerful body extends the mandate of the mission, known as MINUSTAH, for a final six months during which the 2,370 military personnel will gradually leave.

It creates a follow-on peacekeeping mission for an initial period of six months comprising 1,275 police who will continue training the national police force. The new mission will also assist the government in strengthening judicial and legal institutions “and engage in human rights monitoring, reporting and analysis.”

The United States is currently reviewing the U.N.’s 16 far-flung peacekeeping operations to assess costs and effectiveness. U.S. ambassador Nikki Haley told the Security Council on Tuesday that thanks to recent elections in Haiti “the political context is right” for a new and smaller mission.

The resolution recognizes “the major milestone towards stabilization” achieved by the successful holding of presidential and legislative elections and the country’s return to “constitutional order.”

But it also recognizes the need for international support to strengthen, professionalize and reform the police — and to help the country promote economic development and face the “significant humanitarian challenges” following Hurricane Matthew which struck last October.

The mission also has been dogged by controversy in recent years. U.N. troops are widely blamed for introducing cholera that has killed at least 9,500 people in Haiti since 2010. And some troops also have been implicated in sexual abuse. At least 134 Sri Lankan peacekeepers exploited nine Haitian children in a sex ring from 2004 to 2007, according to an internal U.N. report obtained by The Associated Press.

The U.N. resolution reiterates the need for security in the country to be accompanied by efforts to address “the country’s extreme vulnerability to natural disasters.”

Sandra Honore, the U.N. envoy for Haiti, told the council on Tuesday that “Haiti’s political outlook for 2017 and beyond has significantly improved” following elections.

This has opened “a crucial window of opportunity to address the root causes of the political crisis” that preceded the elections and address “the many pressing challenges facing the country,” she said.

The council also authorized the new mission, to be known as MINUJUSTH, “to protect civilians under imminent threat of physical violence” in areas where it’s deployed and “to use all necessary means” to carry out its mandate.