In an “anything is possible” game, this is fair. In this kind of game, it is necessary for players to actually, truly believe that they can get themselves into so much trouble that they will not have a “final warning” that their PC is about to die, and Death is the most (and often only) effective teacher in this regard.*
And fortunately, players always get another chance at RPG “life” with a new character.
Look at it another way: if you had strained the group's suspension of disbelief to give this player multiple chances to escape after it was obviously dire straits, they would have seen it for the deus ex machina that it is. Swooping in to visibly save the PC after the party made the choice to go in and publicly murder a high-ranking NPC in their stronghold would have only taught them that death is rarely a possible consequence of even the most disastrous choices, because you will always be metaphorically running around underneath them with a safety net. A game with every sharp corner swaddled in soft padding is not an “anything is possible” game.
In fact, this lesson came cheaply: nearly everyone escaped alive, and they learned a valuable lesson: plan your missions! Scout the area, know the escape routes, have an ingress plan and an extraction plan, and failure can easily mean death. This is a lesson they would not have learned otherwise.
In the kind of game you're running, pulling your DM punches does players no favours, because they learn that the world is safe and that you will always pull their fat from the fire. In the kind of game you're running, deaths that can obviously be traced back to a poor decision are immediately valuable to everyone and will improve their skill as players. No player in our modern world knows how to survive in a lethal world of magic and monsters before they start playing in a campaign, and this is really the only way to learn. It's the only way any roleplayer has ever learned how to excel in a high-stakes game.
Yes, it was entirely fair. And in the kind of game you're running, necessary. Next time, they'll be cleverer and be more awesome. Think of it as investing in their future amazingness as heroes — amazingness they will have earned instead of been given.
In a different kind of game, it could have been totally unfair. If anyone tells you that you're being unfair, they're either misunderstanding the kind of game you're running, sufficiently unaware that it's a possible valid play style to recognise it from your description, or just disagreeing on a philosophical level that any group should be encouraged to play in this manner that lots of people find invigoratingly fun and challenging.
All else being equal, of course
Whether death-by-poor-choices can ever be fair is separate from a few other things. Since it's separate, the above considers only fairness with all else being equal.
So, that this is fair does not mean that talking with your players to set expectations isn't still a great idea. An out-of-game discussion about what the game's fundamental challenges are about can deal with the low-hanging conflict-fruit of players just not realising the kind of game you're going to be running. A talk can't truly prepare players who are unfamiliar with this kind of game though, just prepare them to be unprepared, so a talk can't substitute for learning “in the field” by trial and error. (If you didn't have a talk about expectations before starting the campaign, now is the time to check in with your players and have that talk if necessary.)
Nor does it mean that there is never any room for you to increase your skill at GMing and adjudicating these situations as they approach. The players' skill at recognising and exploiting opportunities is gated by your own ability to communicate (with hints or more overt indicators) that such an opportunity exists. That's a skill to hone at every opportunity, especially in self-reflection post-mortem.
All else being equal, it is fair to have PCs die suddenly due to circumstances of their own creation. Allow them to rise to the occasion and make sure you are rising to the occasion, and you'll maximise the empowerment and fun that is possible in a game that is wide open to anything the players want to try to do, whether clever or ill-considered.
* As opposed to, for example, a Participationist or Illusionist game, in which other concerns take priority in the GM's decision process.