Who is more powerful : an IAS officer or a CM?

When you ask such a question, most people consider this question too simple to even merit answer. They will say, ‘Don't you know that a CM is far more powerful than an IAS officer?’ Their answer is based on perception and not on the basis of real facts. The reality is quite different than the common perception. Let me explain.
Everyone in the government is powerful according to the law of the land. A basic tenet of the Rule of Law is: ‘However high you may be, the law is above you’. The law is made by the Parliament or the State Legislature and not by the PM or CM. 
The IAS, IPS, IRS or other officers implement the laws. When you go through the fine prints of the law, you will find that rarely the power is given to a politician (including CM) and all the power is vested with the officers. For example, in Customs and Central Excise department, all refunds have to be given by the Assistant Commissioner level officer (or above) even if the amount is 1000 Crores. If he refuses to sanction or reject the refund, even a FM or a PM can’t sanction it.  You have to then go to Commissioner (Appeals) for sanction it and then to Tribunal/High Court/Supreme Court. The Ministers have no power to sanction any refund or give any permission or sanction unless these power are specifically vested to them by the laws passed by the Parliament. They can’t even give any written or oral direction to an officer to perform the function in a particular way. In fact, even if the claim of FM/PM or even President of India is pending before the Tax department, only the competent officer can sanction and nobody else. The same holds good for all officers whether belonging to IAS, IPS or any other service.
I remember an instance when Mr M N Buch, an IAS officer of MP Cadre was called for a lecture in our Academy (NPA) during probation days. He told us, ‘Everyone must have taught you that you are a servant. I will tell you that you are not a servant but a ‘Ruler’. By ruler I don’t mean that you are a king or something but that you are the sole implementer of rules and laws made by the Parliament. You and only you can implement that law and no one can take that power from you. These laws are transparent and known to everyone. Follow the laws and you will be the ruler.’
I agree with him fully. We as officers derive the powers from the laws of the land and not from the direction of any bosses. The PM or CM can transfer an officer (a power which is given to them) if he does not like his action but nothing more. Once the decision is taken, it can’t be changed by anyone in the country except when it is illegal and that too after following the proper procedures.
We are in democracy and here no one has absolute power. The CM/PM of today may become nobody tomorrow but the officers would be here for 35-37 years, if they observe the laws and procedures and exercise their power in fair and just manner.  The political masters have to work only with them and not by themselves.