South Africa's President Cyril Ramaphosa has officially launched a new border force in a bid to tighten the country's porous borders.
The inauguration took place in the town of Musina, home to the busy Beitbridge border post with Zimbabwe.
Mr Ramaphosa said increasing numbers of undocumented foreign nationals had "exacerbated many of the country's social and economic problems".
Immigration is one of South Africa's most pressing political issues.
Managing its borders has become disorganised, with pressure on the government to do more to reduce the numbers of people coming into sub-Saharan Africa's most developed country from its neighbours.
At the same time, xenophobia by political parties is fanning flames ahead of the 2024 elections, to mobilise support from dissatisfied South Africans.
Until now, the task of policing the borders was shared by four different government departments. They were also subject to 58 acts of parliament.
But now the Border Management Authority, which cost millions of dollars to set up, is South Africa's third law enforcement agency after the police and army.
The establishment of the agency means South Africa now has an integrated border policing bureau with a single command and control.
Hundreds of border guards have been recruited and will be working together with the defence force. They will be manning South Africa's ports of entry which include eight seaports, 52 land borders and eleven international airports.
The launch was also attended by Zimbabwe's President Emmerson Mnangagwa, who had talks with Mr Ramaphosa beforehand.
The South African leader said the two men had agreed that "our countries want to live in harmony as neighbours".
Mr Ramaphosa said the Border Management Authority was a vital link in harnessing the benefits of the African Continental Free Trade Area, as well as curbing illegal migration and human trafficking.
Other problems have added to South Africa's border control woes in recent times.
A multi-million-dollar fence which was erected between South Africa and Zimbabwe collapsed, making it difficult to stop illegal immigration.
And over the years, a large number of law enforcement officers have been arrested for corruption after demanding bribes.
South Africa conducted a census in 2022, with the results expected to be released on 10 October.
Data released following the 2011 census revealed that 3.96 million foreign-born people lived in South Africa, including undocumented migrants. Statistics South Africa said this translates to about 6% of the country's population.
Many believe the number of illegal immigrants could be much higher, as the government is often accused of not taking bolder steps to tackle the influx of undocumented foreigners.
Other organisations, such as anti-migrant street movement Operation Dudula, have accused illegal migrants of contributing to the high levels of crime.
The immigration debate is often marred by bouts of violence, xenophobia and misinformation, as unemployed South Africans have been made to believe that their jobs are being taken by undocumented migrants from other African countries.
Earlier this week, Operation Dudula forced the closure of shops owned and run by non-South Africans in Soweto. This comes after two children died after consuming biscuits bought from one of the local shops.