Once you want to leave, you should go, no matter what. Typically by the time you become aware that you want to leave, it means you should have left sometime ago. We typically wait until the we've become extremely dissatisfied to make a change.
Now of course, if the only reason you wanted to leave was salary, then maybe. However your current employer, if the management there is immature - which is a very common situation, may resent your desire for a higher salary and may feel you have held the company over a barrel to get it. So you should probably not accept the counteroffer.
There can be exceptions to this rule, but they are few and far between.
The top and middle management in many companies really resents an employee who leaves or wants to leave. It would vastly prefer to fire or lay off the employee. More than one HR director I have met was very open about this and said the company wanted to get to the point where they had no voluntary separations (i.e. employees wanting to leave) and had only involuntary ones (i.e. firing or layoffs.)

































