I have faced counteroffers several times in my career and debated it at length. The likelihood of taking a compensation bump now to stay and later face a scenario of little to no comp increases because you have put yourself in a situation where you reach the top of your pay band or they just skip the next cycle because of your last pay increase is real. They also know that you caved and would prefer to stay when given a competing offer and after meeting your demands, they'll look to restore the balance.
I would say being a part of a protected class can at least mitigate the motivation for retaliation in this process. Lousy excuses can do for at-will, but once you have a protected characteristic, it becomes a lot easier to correlate any write-ups with discrimination. That being said, I don't ever employ this strategy. It is unwise. Just take a new job, leave, and thank them for your time.