A law which is not just does not seem to me to be a law.
...nothing in the temporal law is just and legitimate which human beings have not derived from eternal law.
Thomas Aquinas, Summa Theologica 1-2.96.4:
I answer that, Laws framed by man are either just or unjust. If they be just, they have the power of binding in conscience, from the eternal law whence they are derived, according to Proverbs 8:15: "By Me kings reign, and lawgivers decree just things." Now laws are said to be just, both from the end, when, to wit, they are ordained to the common good--and from their author, that is to say, when the law that is made does not exceed the power of the lawgiver--and from their form, when, to wit, burdens are laid on the subjects, according to an equality of proportion and with a view to the common good. For, since one man is a part of the community, each man in all that he is and has, belongs to the community; just as a part, in all that it is, belongs to the whole; wherefore nature inflicts a loss on the part, in order to save the whole: so that on this account, such laws as these, which impose proportionate burdens, are just and binding in conscience, and are legal laws.
On the other hand laws may be unjust in two ways: first, by being contrary to human good, through being opposed to the things mentioned above--either in respect of the end, as when an authority imposes on his subjects burdensome laws, conducive, not to the common good, but rather to his own cupidity or vainglory--or in respect of the author, as when a man makes a law that goes beyond the power committed to him--or in respect of the form, as when burdens are imposed unequally on the community, although with a view to the common good. The like are acts of violence rather than laws; because, as Augustine says (De Lib. Arb. i, 5), "a law that is not just, seems to be no law at all." Wherefore such laws do not bind in conscience, except perhaps in order to avoid scandal or disturbance, for which cause a man should even yield his right, according to Matthew 5:40-41: "If a man . . . take away thy coat, let go thy cloak also unto him; and whosoever will force thee one mile, go with him other two."
Secondly, laws may be unjust through being opposed to the Divine good: such are the laws of tyrants inducing to idolatry, or to anything else contrary to the Divine law: and laws of this kind must nowise be observed, because, as stated in Acts 5:29, "we ought to obey God rather than man."
Martin Luther King, Jr., "Letter From a Birmingham Jail":
You express a great deal of anxiety over our willingness to break laws. This is certainly a legitimate concern. Since we so diligently urge people to obey the Supreme Court's decision of 1954 outlawing segregation in the public schools, at first glance it may seem rather paradoxical for us consciously to break laws. One may want to ask: "How can you advocate breaking some laws and obeying others?" The answer lies in the fact that there are two types of laws: just and unjust. I would be the first to advocate obeying just laws. One has not only a legal but a moral responsibility to obey just laws. Conversely, one has a moral responsibility to disobey unjust laws. I would agree with St. Augustine that "an unjust law is no law at all"Now, what is the difference between the two? How does one determine whether a law is just or unjust? A just law is a man-made code that squares with the moral law or the law of God. An unjust law is a code that is out of harmony with the moral law. To put it in the terms of St. Thomas Aquinas: An unjust law is a human law that is not rooted in eternal law and natural law.
Matthew Henry on Psalm 94.20 ("Shall the throne of iniquity have fellowship with thee, which frameth mischief by a law?"):
It is a pity that ever a throne, which should be a terror to evil-doers and a protection and praise to those that do well, should be the seat and shelter of iniquity. That is a throne of iniquity which by the policy of its council frames mischief, and by its sovereignty enacts it and turns it into a law. Iniquity is daring enough even when human laws are against it, which often prove too weak to give an effectual check to it; but how insolent, how mischievous, is it when it is backed by a law! Iniquity is not the better, but much the worse, for being enacted by law; nor will it excuse those that practise it to say that they did but do as they were bidden. These workers of iniquity, having framed mischief by a law, take care to see the law executed; for they gather themselves together against the soul of the righteous, who dare not keep the statutes of Omri nor the law of the house of Ahab; and they condemn the innocent blood for violating their decrees. See an instance in Daniel's enemies; they framed mischief by a law when the obtained an impious edict against prayer (Dan. vi. 7), and, when Daniel would not obey it, they assembled together against him (v. 11) and condemned his innocent blood to the lions.