Construction of the castle took twenty-one years, from 1366 to 1387. The gate, originally called the 'Gate of Gathering Treasure' carries a legend from the time of its creation in the early Ming Dynasty. According to the legend, when Zhu Yuanzhang, the first emperor of the Ming Dynasty (1368-1644), had the gate built, the ground kept sinking. The gate collapsed again and again. It was not until a treasure bowl was buried underground that it stood firm. In 1931, to commemorate the revolution of 1911 and the Republic of China (1919-1949) that emerged as a result, the Gate of Gathering Treasure was renamed Zhonghua Gate. In Chinese Pinyin, Republic of China is written as Zhonghua Minguo.
Nanjing was the capital of China during the Ming Dynasty under the reign of Emperor Zhu Yuanzhang. (Zhu Di, the son of Zhu Yuanzhang, moved the capital to Beijing in 1420.) In 1366, Zhu Yuanzhang began to build a wall around the city of Nanjing to defend it from attack. The Gate of Gathering Treasure was built on the site of a previous gate, the south gate of the city built during the Later Tang Dynasty (923 - 936). The new one, the grandest among the thirteen gates of the new castle, was an architecturally complex structure composed of three closed courtyards and four arched doors serving as the entrance. There were double paneled wooden doors and with additional stone door set behind. If the enemy broke through the wooden doors, they could be separated and trapped in the three closed courtyards upon dropping the stone doors.
Twenty-seven tunnels were built in the castle to store large quantities of food and weapons and to hold approximately 3000 soldiers. Wide and steep ramps were built on the east and west side to allow people to carry materials upward. The entire structure was built with massive bricks mortared together with special cement made from lime, sticky rice juice and tung oil. In order to guarantee the quality of the construction, every brick underwent a strict quality control process. The brick makers and builders were ordered to mark their names on each brick. Even today, it is possible to find Chinese characters and numbers on the bricks. No doubt, this detailed attention to quality of construction is one of the reasons why the condition of the castle remains so remarkably good today.