"The first state to legalize enslaving Africans was Massachusetts."
Correction. Make that the first American colony.
States is correct. In 1780, 4 years after the Declaration of Independence, while the Revolution was still being fought, both Massachusetts and Pennsylvania passed legislation ending slavery in their "States." They were the first "Governments" in the world to do so -- 50 years before the British Parliament acted.
As Colonies under Royal Governors, they would not have been permitted to end slavery.