During the American colonial period, slavery was legal and practiced in all the commercial nations of Europe. The practice of trading in and using African slaves was introduced to the United States by the colonial powers, and when the American colonies received their common law from the United Kingdom, the legality of slavery was part of that law.
Trade in slaves was abolished shortly after the formation of the United States, by Act of Congress on March 2, 1807. Many states took steps to abolish slavery within their borders even before the formation of the federal government, and several states even routinely emancipated slaves who came within their borders.
At the time of the Amistad case, then, slave trade was illegal throughout the United States, but the legality of slave ownership varied from state to state. In New York and Connecticut, the primary states involved in the Amistad case, slavery was illegal.