SEOUL, SOUTH KOREA — A South Korean charter plane left for the U.S. on Wednesday to bring back Korean workers detained in an immigration raid in Georgia.

A total of 475 workers, more than 300 of them South Koreans, were rounded up in the Sept. 4 raid at the battery factory under construction at Hyundai’s sprawling auto plant west of Savannah. U.S. authorities released video showing some being shackled with chains around their hands, ankles and waists, causing shock and a sense of betrayal among many in South Korea, a key U.S. ally.

South Korea’s government later said it reached an agreement with the U.S. for the release of the workers.

South Korean TV footage showed the charter plane taking off at Incheon International Airport, just west of Seoul, on Wednesday morning. The plane will return to South Korea with the detained workers on Thursday afternoon, media reports said.

South Korea’s Foreign Ministry earlier said it was pushing to have the charter plane depart from the U.S. as early as Wednesday U.S. time.

The workplace raid by the U.S. Homeland Security agency was its largest yet as it pursues its mass deportation agenda. It targeted Georgia, where many large South Korean businesses operate and plan future investments. Only weeks ago, South Korea promised hundreds of billions of dollars in U.S. investments to reach a tariff deal. U.S. President Donald Trump and South Korean President Lee Jae Myung held their first summit in Washington on Aug. 25.

Trump said this week the workers “were here illegally,” and that the U.S. needs to work with other countries to have their experts train U.S. citizens to do specialized work such as battery and computer manufacturing.

Atlanta immigration attorney Charles Kuck, who represents four of the detained South Korean nationals, told The Associated Press on Monday that no company in the U.S. makes the machines used in the Georgia battery plant. So they had to come from abroad to install or repair equipment on-site — work that would take about three to five years to train someone in the U.S. to do, he said.

Many South Koreans view the Georgia raid as a source of national disgrace, but experts say the country won’t likely take any major retaliatory steps given its deep military and economic ties with the U.S. But they say the bilateral relationship could suffer a setback if a similar incident occurs again.

The South Korea-U.S. military alliance, forged in blood during the 1950-53 Korean War, has experienced ups and downs over the decades. But surveys have shown a majority of South Koreans support the two countries’ alliance, as the U.S. deployment of 28,500 troops in South Korea and 50,000 others in Japan has served as the backbone of the American military presence in the Asia-Pacific region.

During a Cabinet Council meeting on Tuesday, Lee said he felt “big responsibility” over the raid and expressed hopes that the operations of South Korean businesses won’t be infringed upon unfairly again. He said his government will push to improve systems to prevent recurrences of similar incidents in close consultations with the U.S.