I once got fired that way...
I won't give too much details, but basically it was this:
Bigwig liked me.
Guy directly under bigwig, was my theoretically boss.
back then I didn't understood office politics, and kept communicating with bigwig directly, because project was his idea, and his coding style was similar to mine (when he used to code) so he understood what I was doing.
I made a genuine screwup due to mental illness (now treated), guy under bigwig fired me.
I complained to bigwig on the same day, he unfired me.
I still had screwed up though... so bigwig gives me some deadline to fix my stuff.
Some weeks later, about 3 days before deadline, bigwig had to take a business trip...
So guy under bigwig shows up, tell me to show him "now" the project, since I was counting on using all the days on the deadline, it wasn't ready, so he tells me I failed and I was fired.
I tried to argue, and find bigwig... but he didn't let me, instead he made me get escorted out of the building, I didn't even got to clean my desk (like 2 years later a co-worker that grabbed my stuff returned them to me when we went to the same event).
Of course I still tried to contact bigwig, but I just wanted to ask my stuff back. Found out that they deleted my e-mail, blocked my personal e-mail from their server, reception stonewalled me (kept giving me obvious excuses to not pass on my call to anyone), banned me from the building (that had other companies too but...) and so on.
And that is how I found out the hard way how office politics work...