Feudalism emerges in Europe as a political and economic system based on landholding and protection in exchange for services. As invaders like the Vikings, Magyars, and Muslims attacked Europe, feudalism structured society into a pyramid with the king at the top, lords and nobles below providing land grants to vassals who became knights and protected the land. Society was divided into those who fight, those who pray, and those who work, mainly peasants who lived on self-sufficient manors providing goods to the lord in exchange for housing and protection.