 Thus, these two factions became involved in a struggle in this area, intermittently controlling it as the balance shifted.During the reign of King Emeric, the Dalmatian cities separated from Hungary by a treaty.A consistent period of Hungarian rule in Dalmatia was ended with the Mongol invasion of Hungary in 1241.