The first known civilization or state in West Africa was the Kingdom of Ghana. Ghana was founded long before European contact, sometime between the 2nd and 4th centuries AD. The people who founded the kingdom are known as the Soninke or the Sondinke. Ancient Ghana was not in exactly the same place modern day Ghana is, but it was in West Africa. Ghana came to the attention of the outside world through Muslim traders by the 800s AD.
Ghana was a kingdom that was built on trade even though Ghana did not itself control the things being traded. To the south of Ghana, there were large gold deposits. To the north there were areas where salt was plentiful. Ghana did not control either area, but the trade in both commodities went through Ghana, thus allowing Ghana to control the trade.
In time, the trade expanded and Muslims became a part of it as Islam expanded into the area. By the 11th century, Ghana had become a Muslim state. It was first foothold that Islam got in that area of Africa.