Same way we always did? The 4 "M's" of running combat.
1. Movement
2. Missile
3. Magic
4. Melee
(4a or 5: Missile a second time for long and short bows)
The mages have to stay back, think clearly and concentrate. If they get hit before their spell goes off *fizzle city*. Practically any average-intelligence foe is going to know that when the guy in the robes starts waving his hands and mumbling weird syllables, "AH! She's using magic!!! Try to hit her if you can!"
And pretty much any adventuring melee fighter knows (or should) that even if you're a "swordsman" or an "axeman" or whatever, you should be carrying a spear or javelin or shortbow, a light crossbow or something to hit things (in this case goblinoid shaman, witch-doctors, evil cultists or wizards) from afar if/when you have to.
No, obviously, this doesn't "balance" everything...but it worked mighty fine for a long while.