Background:
I have had the following experience a few times in my life.
I was working under contract for a company through an agency. The manager/PM that I would be working with would declare to us that his budget is such that he cannot afford any of us to bill overtime.
The agency would establish a firm 'bill for every hour worked' rule. Clearly they want to make as much money from us as possible, and they have a firm contract with both, us (the devs), and the client.
At some point the PM would come up to us and say something along the lines of "Hey guys, we really need this done by tomorrow" hint-hint, nudge-nudge.
Analysis:
It's pretty obvious that in this situation the PM is trying to squeeze out as much productivity out of every developer for the least amount of money as possible. This is understandable, we were expensive, and our agency was charging a hefty margin. In a typical MNC there is a theme whereby a manager who delivers projects under budget will get promoted faster, be held in higher regard, etc.
However, this puts people like me in a difficult predicament. I'm either breaking the rules (in fact, contractual obligations) by not billing all of the hours with my agency. Or I am not being a 'team player' within the place where I actually spend my every working day.
The Risk:
The PM/manager will be my reference for the next job, they will have the power to say 'I prefer to have this guy's contract extended' vs. not, etc. They have a non-trivial influence over your career.
Question:
What is the best way to handle these situations, where the PM's direct career interests seem to be contradicting your contractual obligations?
*FWIW In the past I would sometimes work unbilled hours, and sometimes tell my PMs that I can't depending on the state of the project and the severity of problems. But every single time it felt like I did something wrong, because on one hand working unbilled hours would put other contractors that did not make the same choice as me in a negative light, but on the other hand walking off at 5:00pm when the project is in dire straits seems irresponsible.