When does a state violate international law?
The rules of international law regulating the responsibility of states.
A state violates international law when it commits an "internationally wrongful act" - a breach of an international obligation that the state was bound by at the time when the act took place. A state is bound to act according to international treaties it signed.
The Articles on State Responsibility for Internationally Wrongful Acts, developed by the International Law Commission (ILC), represent customary international law, which makes them binding on all states. They outline when, how, and who violates international law, and what the consequences of those violations are.
Exceptions or justification for violating international law
There are a number of exceptions when an act that normally would be a violation of international law, does not create responsibility of the state involved.
These exceptions, however, do not apply to violations of IHL and international human rights law (IHRL): IHL and human rights set out minimum standards of protections. Exceptions are not applicable since they would undermine the entire system of IHL and IHRL.
In other circumstance, exceptions are possible in cases of consent, self-defence, or necessity (ILC, Articles 20-26):
Consent: Under certain circumstances, it is possible for one state to consent to a violation of international law of another state. For example, a state may allow another state to use its air space or waters, without considering the invasion an act of aggression.
Necessity: If an act by a state (that may be considered illegal) was the only way for a state to safeguard an essential interest against a grave and imminent danger (and it does not damage another essential interest), that state does not violate its international obligations.
Self-defence: A state cannot be held responsible if it acted in self-defence. The UN Charter sets out in article 51 the rules on when the use of force can be used in self-defence.