What legal action during the civil war ended slavery in the states that had left the union?

The Emancipation Proclamation, issued on January 1, 1863, is the legal action that ended slavery in the states that had left the Union during the Civil War. This executive order, issued by President Abraham Lincoln, declared that all enslaved people in the Confederate states were to be set free. However, it is important to note that the Emancipation Proclamation did not immediately free all enslaved people in the United States, as it only applied to states that were in rebellion against the Union. It took the passage of the 13th Amendment to the United States Constitution in 1865 to formally abolish slavery in the entire country.