I make a distinction between legality and morality. There are many things which are both legal and moral, and quite a few which are illegal and immoral. In between, there are acts which are illegal and moral, and acts which are immoral and legal.
Not everything which is immoral should be illegal. It would be immoral and downright lousy for me to promise to pick my friend up from the airport if I have no intention of doing so, yet to make a law that addresses this would be the height of absurdity and tyranny.
Likewise, many of our laws address things which are not immoral. There is nothing inherently immoral about running a stop sign. If there are no cars or pedestrians around, this action carries no moral weight. (On the other hand, if the roads are covered with a layer of sheer ice, as is often the case in Calgary, it may very well be dangerous to attempt a full stop.) An arbitrary law does not bring a moral dimension to an inherently amoral action (an action which lacks a moral dimension).
Just as I make a distinction between legality and morality, I make another distinction between power and authority. Power is the ability to act, and is amoral. Authority the moral element, which determines whether or not use of power is legitimate.
One can have authority and power, or lack either or both of these elements. The State and the State's police force have power, but authority is not guaranteed. The State does not create its own authority, and a 51% majority does not create authority.
"[T]here is no authority except from God, and those that exist have been instituted by God." (CCC 1899)
What does this passage mean? Well first I will say very certainly: it does not mean that the State has authority given to it by God. The State can have authority, but it does not necessarily possess it.
One has authority when he stands for morality and natural law. I have morality when I defend myself, or my family, or my friends from aggression at the hands of a criminal. The Pope has authority when he speaks on behalf of the unborn. The Canadian government and the American Government have no authority whatsoever when they fund abortions, or recognize them as a "right". They have no authority when they tell you what you can eat, or drink, or buy, or by what methods you may protect yourself.
The governments have power though, and if we don't listen, we will be fined. If we don't pay their graft, we will be imprisoned. If we resist, we will be killed. So we listen, down the barrel of a gun wrapped in the guise of "the common good".
Now I finally get to the point which I had set out to make:
A legitimate State may act with no more authority than any single individual possesses.
Authority does not derive its moral legitimacy from itself (CCC 1902), so therefore any State may only do what its citizens already have the moral authority to do themselves. Nobody, not even the State, has the authority to do or enforce that which is immoral. The State has the power to do so, which it has continually exercised, however when we resist tyranny, we do so with authority (if not with power).
Everybody, whether appointed by the State or not, may only do that which is moral.