forces in the second phase of the war. The effort of the Japanese garrison (about 7,000 men) of Ulsan was largely dedicated to its fortification in preparation for the expected attack. Katō Kiyomasa assigned command and defense of the base to Katō Yasumasa, Kuki Hirotaka, Asano Nagayoshi, and others before proceeding to Sosaengpo near Ulsan. The Ming army's first assault on January 29, 1598, caught the Japanese army unaware and still encamped, for the large part, outside Ulsan's unfinished walls. A total of around 36,000 troops with the help of singijeons and hwachas nearly succeeded in sacking the fortress, but reinforcements under the overall command of Mōri Hidemoto came across the river to aid the besieged fortress. Although the Japanese garrison was desperately short of supplies, the Ming commander Ma Gui judged the situation to be going against the allies, because more and more Japanese forces began to arrive from the surrounding area and the allied forces were quickly becoming outnumbered. Late one night, Ma Gui decided to order a general organized retreat of the allied forces, but soon confusion set in, and matters were further complicated by heavy rainfall and harassing attacks by the Japanese. The Chief Superintendent Yang Hao panicked and left hastily for Hanseong ahead of the army.History of the Ming chapter 238 明年正月二日，行長來援，九將兵俱潰。賊張旗幟江上，鎬大懼，倉皇撤師 The general retreat quickly turned into a chaotic rout, of which the Japanese took quick advantage by attacking the retreating Ming and Joseon forces. The retreating Ming and Joseon forces had 20,000 losses. The disaster was a heavy setback for Joseon, who would not be in a position to move on the Japanese position again for more than eight months. Final allied offensive of 1598 After the siege at Ulsan, the two sides remained in a stalemate for the next several months. Xing Jie decided that they would require further reinforcements to launch a final large offensive to permanently remove the Japanese presence on the Korean Peninsula. Reinforcements from China began to pour in through most of mid-1598, with Chen Lin and Deng Zilong and their navy arriving in May. By September 1598, the Ming presence in Korea had swelled to 75,000 overall, by far the largest at any point in the war. Xing Jie divided his forces into four groups, with Ma Gui leading the offensive against Ulsan yet again, Li Rumei (Li Rusong's brother) leading the offensive against Sacheon, Chen Lin