My ideal situation would be:
Keep current job with a pay rise.
However to achieve this I need to decide how to play my hand:
Do I hand in my resignation. See if my company wants to pay to keep me
on. Mention that I have a job offer without resigning and see what
they do. Do nothing and see if I get a pay rise in the future.
First, don't do anything until you get a written offer and everything else you need to feel confident that your new job is yours for the taking.
Then, determine how long you have to make your choice. (If you need to give an immediate answer, then the question is moot. Make your choice and don't look back.)
Assuming you have at least a few days, and assuming your relationship with your manager is reasonably good, then ask for a few minutes with your boss privately.
Tell your boss that you have a good offer for more money from another company. Indicate that your preference is to stay, but that you really need the raise.
Then listen.
There are several possible outcomes:
- Since you have already talked about a raise in the past and been rejected for "whole team" reasons, the most likely outcome is that you will just be asked to serve out your notice period, and then will leave
- It's possible that you will be given a raise now that you have demonstrated that you are ready to leave without one
- It's possible that you will be asked to stay, but not promised an immediate raise
- It's possible (although unlikely) that you will be asked to leave immediately
Be sure you know in your own mind how you will respond to each scenario, since you likely won't have much time to make your decision.
As a long-time manager, I seldom make counter-offers in this situation. My experience tells me that someone motivated enough to go out and find a new job is unlikely to stay long just because I throw more money at her/him. There are always a bunch of reasons people seek jobs elsewhere - giving them a raise isn't likely to change any of those reasons for very long.
You yourself indicated that the no-raise situation has been happening for 2 years, and that the whole team has been affected. If I had to guess, even if you were given a bit more, it seems most likely that you would again feel the need for a raise after a short while and will be right back where you are now.