The Song had trouble keeping peace with nomads in the north, so they formed an alliance with the Jurchens (Jin dynasty). Eventually, the Jurchens claimed independence by founding their own dynasty: the Jin dynasty. They attacked the Song and captured their capital, Kaifeng, bringing an end to the northern Song dynasty. The northerners fled to the south, where the Jurchen armies were not able to conquer. This began the Southern Song dynasty.