In 1597, Japanese decided to attack Korea again, but Japanese force retreated to the southern Gyeongsang province. Without provisions and reinforcements, the Japanese forces had to remain in the coastal fortresses (known as wajō) that they still controlled. The Japanese commander Katō Kiyomasa army were stationed in Ulsan, and Kato built a Japanese castle, Ulsan. Commanders Yang Hao and Ma Gui led an army of 36,000 Chinese, and Commander Gwon Yul led an army of 11,500 Koreans, in a first assault on January 29, 1598. They caught the Japanese army unawares 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 and prolonged the hostilities. Later, the Japanese troops were running out of food and victory was imminent for the allied forces, but Japanese reinforcements arrived from the rear of the Chinese and Korean troops and forced them to a stalemate. After several losses, however, Japan's position in Korea had significantly weakened.