South Africa’s former president Jacob Zuma has been taken into custody to begin a jail term for contempt of the country’s highest court, ending a stand-off that challenged the rule of law in Africa’s most industrialised nation.

Zuma was taken to jail late on Wednesday with just minutes to spare before a midnight deadline to arrest him, South Africa’s police ministry said.

South Africa’s constitutional court sentenced Zuma to 15 months last week for defying its order to attend a judicial inquiry into allegations he aided systematic corruption during his presidency, which ended in 2018.

The judgment was hailed as a victory for South Africa’s post-apartheid constitution but it became a test for the status of the rule of law under the governing African National Congress after Zuma continued to ignore the judges and allies threatened violent resistance to the order.

Zuma missed a Sunday deadline to turn himself in, which obliged the police to follow a court order to arrest him by the end of Wednesday, despite last-minute legal attempts by the former president to seek a reprieve.

His foundation on Wednesday said he “decided to comply with the incarceration order” and was “on his way to hand himself into a correctional services facility” in KwaZulu-Natal, his home province.

Zuma’s own protection team of police officers took him into custody just as a convoy of police vehicles converged on his Nkandla compound, according to South African media. A motorcade then whisked him to a prison in Estcourt, a town about 200km away.

During his nine years in power, Zuma presided over the decay of institutions and economic stagnation, culminating in the so-called state capture scandal and claims that he helped to loot public resources.

Zuma denies any wrongdoing.

His jailing marked a turning point for the ANC and for Cyril Ramaphosa, Zuma’s successor as party leader and president, who has pledged to rebuild state institutions.

“Without doubt this is a difficult period in the movement” but the party respects the supremacy of South Africa’s constitution, the ANC said in a statement on Thursday.

The fact that Zuma’s own state-provided security detail took him into custody showed that the “robustness” of South Africa’s institutions had won out in the end, said Sithembile Mbete, a political scientist at the University of Pretoria.

Despite concerns that the police would quail from following the court’s order, “they have done their job . . . a constitutional crisis has been averted”, Mbete said.

Next week, the constitutional court will hear Zuma’s challenge to rescind the sentence, while a judgment is expected on Friday on a separate attempt to interdict the order in a lower court.

The 79-year-old had breathed defiance to the last. He said as late as Sunday that “sending me to jail during the height of a pandemic at my age is the same as sentencing me to death”, after a show of force at his homestead.

But by Wednesday, these supporters had dwindled, and as South African television stations showed Zuma’s motorcade sweeping out of the homestead just before midnight, none took up arms.