South Korea’s anti-corruption agency says impeached president Yoon Suk Yeol has been detained over his imposition of martial law last month.

In a video message recorded before he was escorted to the headquarters of an anti-corruption agency, Mr Yoon lamented that the “rule of law has completely collapsed in this country”, but said he was complying with the detention warrant to prevent clashes between law enforcement officials and the presidential security service.

A series of black SUVs, some equipped with sirens, were seen leaving the presidential compound with police escorts.

A vehicle apparently carrying the president later arrived at the Corruption Investigation Office for High-Ranking Officials in the nearby city of Gwacheon.

Investigators from the state anti-corruption agency and police officers make their way to the residence of impeached president Yoon Suk Yeol (Ahn Young-joon/AP)

Mr Yoon was brought into custody about three hours after hundreds of law enforcement officers entered the residential compound in their second attempt to detain him over his imposition of martial law last month.

His lawyers tried to persuade investigators not to execute the detention warrant, saying the president would voluntarily appear for questioning, but the agency declined.

Mr Yoon has been holed up in the Hannam-dong residence in the capital Seoul for weeks while vowing to “fight to the end” against the efforts to oust him.

He has justified his declaration of martial law on December 3 as a legitimate act of governance against an “anti-state” opposition employing its legislative majority to thwart his agenda.

Investigators are likely to ask a court for permission to make a formal arrest. Otherwise, he will be released after 48 hours.

The officers seemingly encountered no meaningful resistance from presidential security forces as they approached Mr Yoon’s residence and there were no immediate reports of clashes.

Supporters of impeached South Korean President Yoon Suk Yeol shout slogans during a rally to oppose his impeachment near the Constitutional Court in Seoul (Lee Jin-man/AP)

The anti-corruption agency is leading a joint investigation with police and the military over whether Mr Yoon’s martial law declaration amounted to an attempted rebellion and sought to bring him into custody after he ignored several summons for questioning.

Officers seemingly encountered no meaningful resistance from presidential security forces as they approached Mr Yoon’s residence and there were no immediate reports of clashes.

Following an hours-long standoff at the compound’s gate, anti-corruption investigators and police officers were seen moving up the hilly compound. Police officers were earlier seen using ladders to climb over rows of buses placed by the presidential security service near the compound’s entrance.

Despite a court warrant for Mr Yoon’s detention, the presidential security service has insisted it is obligated to protect the impeached president and had fortified the compound with barbed wire and rows of buses blocking paths.

South Korea’s acting leader, deputy prime minister Choi Sang-mok issued a statement early on Wednesday urging law enforcement and the presidential security service to ensure there are no “physical clashes”.

South Korea’s Constitutional Court’s judges sit for the first formal hearing of a trial on the validity of president Yoon Suk Yeol’s impeachment by the National Assembly at the constitutional court of Korea in Seoul (Kim Min-Hee/Pool Photo/AP)

The liberal opposition Democratic Party, which drove a legislative campaign that led to Mr Yoon’s impeachment on December 14, issued a statement calling for the presidential security service to stand down and co-operate with Yoon’s detention. Members of Mr Yoon’s People Power Party held a rally near the presidential residence, decrying the efforts to detain him as unlawful.

Mr Yoon’s supporters and critics have held competing protests near the residence — one side vowing to protect him, the other calling for his imprisonment — while thousands of police officers in yellow jackets closely monitored the tense situation.

Mr Yoon declared martial law and deployed troops around the National Assembly on December 3. It lasted only hours before lawmakers managed to get through the blockade and vote to lift the measure.

Mr Yoon’s presidential powers were suspended when the opposition-dominated assembly voted to impeach, accusing him of rebellion.

His fate now rests with the Constitutional Court, which has begun deliberating on whether to formally remove him from office or reject the charges and reinstate him.

The Constitutional Court held its first formal hearing in the case on Tuesday, but the session lasted less than five minutes because the president refused to attend.

The next hearing is set for Thursday and the court will then proceed with the trial, whether or not Mr Yoon is there.