Since the Boxer Rebellion began in Laishui, Deputy Commander Yang Futong was sent by the Governor to suppress them, but he ended up being killed. The court shifted the blame onto the official army and refused to provide compensation, which left everyone bewildered. At that time, the chaos caused by the Boxers was intense and could not be contained immediately, so the area around the capital was quickly affected. General Nie Shicheng, who was serving as the Governor of Zhili at the time, led the entire army stationed in Lutai. Governor Yulü immediately ordered a few battalions to be sent to Zhuozhou and deployed additional battalions to secure the Beijing-Tianjin area. On May 8th, the Boxers burned the railway in Huangcun. Nie's troops went to rescue, but the Boxers suddenly attacked and wounded dozens of people, which infuriated Nie's soldiers. Afterwards, Nie's army repeatedly attacked the Boxers along the way, especially in the battle of Luofa, where many Boxer members were killed. The Boxers, enraged, sent their supporters to the court to lodge complaints. At that time, there were already officials in the court colluding with the Boxers, fabricating excuses to file grievances. The court issued a stern reprimand to the Zhili troops for causing disturbances and stated that Nie Shicheng was a senior general leading a well-trained and disciplined army. If provoked, the Boxers' animosity toward him would intensify, leading to more conflicts. Therefore, they attempted to mediate by dispatching a Manchu military commander, a high-ranking official, to write a letter to Nie Shicheng, essentially stating, "Your army's attire is very similar to that of foreigners, which easily arouses suspicion from the Boxers, so they provoke trouble. The Boxers' goal is to serve the country with loyalty and should not be indiscriminately slaughtered. You must be cautious!" After receiving the letter, Nie Shicheng replied, "The Boxers bring disaster to the country and the people, which will lead to major problems. As the Governor of Zhili, I have the responsibility to eliminate them in my jurisdiction. Even if I suffer heavy losses, I will not shy away from any challenges!" All these events occurred before May 12th and 13th.

At that time, Nie Jun was mainly responsible for guarding Yang Village, preventing the bandit forces from moving south. On the 14th, British General Seymour led the allied forces into Beijing, passing through Yang Village. General Nie wanted to discreetly allow them to pass, so he sent a telegram to Yu Lu, but Yu Lu disagreed. General Nie, furious, told his subordinates, "Since I am the governor of Zhili, if there are bandits in Zhili that cannot be eradicated, and if there are enemies in Zhili that cannot be stopped, what good is this army?" He originally intended to lead the entire army back to Lutai, but ultimately did not go through with it. As a result, he kept holding back the Western army in this area, preventing them from advancing quickly. The Westerners, due to insufficient troops and wary of the Nie army's camp in the rear, decided to return directly. However, the court, however, believed the local militia deserved credit and awarded them a large sum, while the Nie army received nothing.

After the 20th, the court finally received the news of the loss of the Dagu Fort, which officially decided to go to war against the foreign powers. General Nie was immediately ordered to attack the Tianjin concession. Both sides engaged in fierce battles, clashing over a dozen times, with a stalemate lasting eight days and continuous cannon fire. The Western forces reported that since the war with China began, they had never encountered such a brave army. Therefore, since the loss of Dagu, Tianjin and Beijing were at risk of falling at any moment, and it was the Nie army that first resisted the Western forces, alleviating the critical situation, allowing Tianjin to hold out for another month right under the noses of the foreigners, and temporarily bringing peace to Beijing.

On the 28th, the main forces of the allied armies arrived to reinforce Tianjin. After a long period of fighting without reinforcements, the situation for the Nie army began to grow dire, but they still retreated near Tianjin City, striving to block the Western army. If there hadn’t been any internal strife and everyone had united against the invasion, General Nie might not have died, the Nie army might not have collapsed, and Tianjin City might have been able to hold out temporarily, waiting for a turnaround. However, it wasn't long before the Nie family was captured by local militia bandits, and the militia aided the bandits in firing upon the Nie army.

At the end of May, Nie Jun launched a fierce assault on the concession. At first, the bandits initially dared to confront them, but after suffering several defeats, they retreated and became onlookers, setting fires, committing murder, and looting indiscriminately. They only dared to confront the official troops. Nie Jun was very angry, believing the bandits were inciting anti-foreign sentiment and causing chaos. Whenever the tide turned against them, they shifted the blame to the official troops. The official troops fought valiantly time and again, with casualties reaching as high as twenty to thirty percent, while the bandits feigned loyalty and righteousness before the court, all the while behaving like outlaws in front of the common people. If they weren't severely punished, how could they justify it to the soldiers and the public? One day, as soon as the official troops returned to their camp after a battle, Nie Jun ordered, "Today, attack the bandits with full force!" Thus, troops were dispatched to attack in all directions, slaughtering thousands of bandits. The bandits hated Nie Jun even more and seized the opportunity during the chaos of Nie Jun's battle with the foreign troops to rush towards his residence. At this time, the main forces of the Western reinforcements were rushing to Tianjin. Nie Jun had just stabilized the situation when he heard this news and quickly led his troops to pursue the bandits. Many of these so-called trained soldiers were largely impulsive and had colluded with the bandits. Seeing Nie Jun pursue the bandits, they sought to rescue them and shouted, "Nie Jun is rebelling!" They opened fire on him. Caught off guard, Nie Jun was ultimately defeated.

At this time, Nie Jun was under attack from all sides, in a difficult position, and he felt very frustrated. As a commander who had led troops for over a decade and had suffered countless injuries, he felt unappreciated by the court and humiliated by the bandits, leaving him filled with rage. Moreover, recently, those treacherous officials and bandits sought to eliminate any rivals and often accused him of colluding with foreign powers, so he considered sacrificing himself for his country to silence them. On June 4th, the cavalry reached Tianjin, and Nie Jun managed to assemble several battalions, fighting day and night, always leading the charge, seeking a glorious end. By the 13th, at Baitai, he was struck by several shells, his abdomen was torn open, spilling his intestines, meeting a heroic end. The circumstances of his death were heart-wrenching, and when people everywhere heard the news, they were filled with sorrow. Just five days after Nie Jun's death, Tianjin fell.