A direct attack on Cumania came only in 1238–1239, and encountered serious resistance by various Cuman khans. The final blow came in 1241, when Cuman control over the Pontic steppes ended and the Cuman–Kipchak confederation ceased to exist as a political entity, with the remaining Cuman tribes being dispersed, either becoming subjects and mixing with their Mongol conquerors, as part of what was to be known as the Golden Horde (Kipchak Khanate) and Nogai Horde, or fleeing to the west, to the Byzantine Empire, the Second Bulgarian Empire, and the Kingdom of Hungary, where they integrated into the elite and became kings and nobles with many privileges. Other Cuman captives were sold as slaves, who would go on to become Mamluks in Egypt, who would attain the rank of Sultan or hold regional power as emirs or beys. Some of these Mamluks led by Sultan Baibars would fight the Mongols again, defeating them at the Battle of Ain Jalut and the Battle of Elbistan.