Out of interest, why didn't you counter the counteroffer at $140k? Realistically, you could've probably gotten $150-155k on the spot, right there. They basically just showed their hand telling they want/need you to stay.
$117k to $140k with perks sounded like a win at the time and I didn't want to push my luck. I really wanted to stay at that point so it was a calculated move to not look too greedy. A year later when I was promoted to director (and raised to $155k + potential $25k bonus) I got to see all salaries (and histories) in the department, and $140k made me the highest paid engineer at that point, so it was a good move. 3 months later after a management shakeup, I negotiated to have the part of that $25k bonus that was in my power ($5k was dependent on hitting sales projections) converted to salary, hence the raise to $175k.
I don't know that it really works that way. At least in my experience, salaries are not generally set by an individual, but require multiple approvals. If they had a prepared counteroffer for $140k, it's not likely that he could've just gotten under the manager's skin and had it amped up to 160k without requiring the manager to go back through the approval process.
If they've prepared a counter at $140, there's a decent chance they're (quietly) allowed to haggle up to some larger number, say between $145 and $160 depending on how much they want you and how much they expect you to negotiate.
They won't tell you what this higher number is under any normal circumstances, and may lie about it, but it probably exists.
If it's small you just have the CEO/founder who decides everyone's salary, if it's a big bigger you have a manager with a margin of negociation but can always get a signoff for a bigger raise by the CEO, and when it gets really big there is a hard grid with categories, ranks within the categories, lower bounds and upper bounds.
i definitely am not. that is one skill i hope to learn before i move on. Granted, i'm pretty happy where i'm at right now, but it could useful in the future...
One helpful tip - if you're not good at it, try to avoid doing it in real-time. Negotiating via email is much easier for beginners.
In face-to-face communications, those not accustomed to negotiating will often give in just based on misread cues. For example, if someone asks how much you want, and you say a number, stop talking until you get a response. Many beginner negotiators will interpret silence as disagreement (even a short amount of silence) and quickly add "but that number is negotiable".
I have this happen all the time when I'm doing profiles of new candidates, particularly when they are junior. They say "I"m looking for 60K, but I am willing to negotiate". I usually respond by telling them they have already backtracked before receiving any objections.
Practice or get some coaching, and until that time, try to do it via email.