That is a lie that has been used for propaganda since the war started and it is told for the purpose of misdirecting people into believing that invading the southern states was justified.
The Northern states passed the Corwin amendment which would guarantee continued slavery in the United States indefinitely. Furthermore, slavery was never under any threat of abolition from the Union until it became advantageous to the war effort to pursue it.
When Lincoln started his invasion of the South, he had absolutely no intention of abolishing slavery.
What the Southern states wanted was economic control over their own trade. You may not be aware of this, but the southern states produced 73% of all the trade with Europe.
The articles of secession clearly stated what it was about, and slavery was abolished after the war.