Negro. It's descended from niger, which is latin for black. Over time, it got shifted into negre, negro, and other variants that became used as a descriptor of African peoples.
As the African slave "trade" kicked up, various and sundry more shifts occurred from the French and Spanish words.
What's kinda funny-weird is that the "hard r" version of the word came along fairly late in the game overall. Earlier pronunciations often lacked that hard r when used in the US slavery regions. Not because of southern drawl, which came later on as well, but because those harr r sounds at the end of words got dropped a lot in hinging multiple languages and accents.
Depending on where you go looking, it's sometimes stated that the French variation is one of the older ones, and (supposedly) never had a hard r in there to begin with.
But, in English, it goes back to before it was used as a slur at all. Waaaay back when, it was just a way of saying someone was dark skinned, and it African descent. It didn't have any weight to it beyond that because chattel slavery and all the bullshit that went with it hadn't kicked off yet. And the older form of that, neger, is the usual spelling, but would be pronounced neg-uh or neg-ah rather than as nig anything.
But, there's people that claim that the specific American version is derived from negro directly, as one of the pronunciations of negro back before the civil war was neg (or nig) ruh, as in someone saying negro as knee-guh-ro or neg/nig-uh-ro; with it eventually dropping that "o" from the end and picking the hard r back up from the latin niger.
The usual etymology is given as a direct line from latin to french and Spanish, then being merged into English and turning from negro to the N-word itself.
Actual original documents are not accessible reliably, and very few have been digitized, so us common folks tend to be limited to reading stuff written about that documents along with the conclusion of a given author. So grains of salt are needed whenever someone tries to be definitive online. Once you get past the etymology of it, which is well understood, there are dozen or so places and times where the word as we know it shifted on spelling and usage as well as pronunciation.
It's a pretty fucking trippy journey, no matter which path you look at for it