Employers are often quick to entertain a counteroffer to a potentially departing employee because the increased salary costs less in the short term than hiring and training a replacement.
It is generally not advisable to accept a counteroffer because the relationship between the employee and employer has now been altered.
The majority of employees that accept a counteroffer either leave or are terminated within a year. There is almost always a non-financial motivation to the resigning employee that is not cured with a salary increase. A good supervisory relationship and open communication about performance expectations, career advancement opportunities, and compensation can help avoid unnecessary turnover.
Changing jobs can be very emotional. It is important to think through, prior to the offer stage, the possibility of your current employer extending a counteroffer at the point of your resignation.