In 1127, following the founding of the Jin in the north, the Song was pushed south and re-established itself at Lin’an, beginning the Southern Song era. It was a time of prosperity with a focus on maritime power. A naval force was established, while harbours and ships were built, merchant ships set sail, and seaports thrived as trading hubs. Defences against the north were maintained and the Yangtze acted as a natural barrier, yet the Southern Song wre always under threat from the Jin and the Mongols, and were many attacks and counterattacks. Eventually, in 1234, the Mongols defeated the Jin, prompting the Southern Song to reclaim lost northern territories. The Mongols, previously Song allies against the Jin, viewed this as an act of aggression. The Southern Song then endured many years of Mongol attack and in 1271 Kublai Khan declared the Yuan dynasty across China. In 1276 Lin’an was captured and, in 1279, when the Song fleet was destroyed, Southern Song finally fell and China was unified.