Also, one thing I forgot to mention that I think is really important...
If the company is prepared to offer you a big enough raise to tempt you to stay, and able to organise that raise at short notice, why didn't they value you enough to give you that raise before then?