How did european nations come to rule most of africa, despite the presence of strong african

How did european nations come to rule most of africa, despite the presence of strong african kingdoms?.