My world is in a time period analogous to the 21st century. Within it, one of the main powers goes to war against a much weaker and highly politically unstable adversary (insurgency groups, revolutionaries, extremists, take your pick). The government justifies this invasion both as a "preemptive strike" and as a humanitarian mission to liberate the populace from... from their country's barbarity I guess? Doesn't matter. The actual reasons are complicated economic and geopolitical factors. But those don't matter either.
Now from the start, the invading country faces discontentment from its own populace which only increases as the conflict goes on. But that's to be expected and it's manageable. But then, just before the war is won, things turn out really bad for the last wave, casualties skyrocket, units are caught completely off-guard by whatever tactics the losing side starts using. They still win, but instances of mental scarring, injury and death are very noticeably higher among the soldiers that served right before the end of the war than those who served anytime before. This doesn't include the occupying forces after the war's end: they're fine.
Since this whole affair is being televised and reported on back home, the result is, of course, widespread anger and backlash against the government from its citizens (who as I previously said, weren't all too keen on this war thing in the first place), demands that various military branches be investigated for flagrant mismanaging the war effort, etc... Basically, it's a big scandal.
But assuming that the people in charge of the war aren't actually grossly inept, what could otherwise cause the war to suddenly become so traumatic for the winning side? What unexpected tactics might the enemy start using? And what would have prevented the invaders from predicting this chance in strategies?
Indeed, why would a war be the most traumatic and casualty afflicting for one side just before that same side wins the conflict? Surely if the losing party is capable of suddenly causing all hell to break loose, they wouldn't be losing at all, would they? The invading military works highly strategically and methodically to avoid loses on its own side as much as possible while eliminating the opposition. They're definitely not just blindly sending troops, on the contrary, it's highly adept at intelligence gathering and applying that information accordingly. So how and why would they suddenly find themselves completely caught off-guard by the enemy just before that same enemy loses?