Slavery had existed in all states at some point prior to the war; however it died a natural death in the northern states because the north was not dependent on a labor intensive agricultural economy as was the South. The foreign slave trade was ended by the Constitution itself which specified a date of 1808 when it could be ended (it actually states it could NOT be ended before that date.) In point of fact, Congress outlawed the trade on January 1, 1808, the earliest date constitutionally possible.
Slavery was actually ended by the 13th Amendment to the Constitution, passed at a time when Southern states were not represented in Congress. Many were required to ratify the amendment as a condition of seating delegates to Congress at the end of the Civil War, so the above answer is somewhat correct. It is a bit simplistic, however, to state that the war was fought solely over slavery. There were larger issues to be decided; however slavery was the catalyst that ignited the flames of war.