Ain’t is found throughout the English-speaking world across regions and classes, and is among the most pervasive nonstandard terms in English. It is one of two negation features (the other being the double negative) that are known to appear in all nonstandard English dialects.
Take ain’t instead of am/are not, add the double negative, and you’ve got ain’t no. Neither are features of Standard English; both, alone or in combination, are features of pretty much all nonstandard English.
Of the two, amn’t, aren’t > an’t > ain’t happened in the 17th and 18th century—certainly in time for it to travel everywhere English is spoken; ain’t is first attested in writing in 1749 per Wikipedia. The Double negative was present in Middle English, and in wide use in the 17th century. (“Up to the 18th century, double negatives were used to emphasise negation.”)
From what I’m seeing in Wikipedia, both ain’t and the double negative were attacked at the same time by prescription. But they were English-wide phenomena; their association with African American English is simply because African American English was somewhat less subject to prescription than white variants of the language.