In the law, qualified immunity is an exemption for liability in civil suits which is extended to government officials in certain circumstances. It is not absolute immunity; simply being a government official does not exempt someone from liability. When a suit is connected to an official's actions when he or she was exercising discretionary duties, however, it may be determined that the official is covered by qualified immunity and thus that the suit cannot go forward.
Several issues must be considered when evaluating a situation to determine whether or not qualified immunity applies in that case. The first is whether or not an official violated a clearly established law or precedent. In the United States, for example, if a law enforcement officer fails to notify someone of his or her Miranda rights at the time of an arrest, this is a violation of the law, and exposes the officer to civil liability. Often, government officials must exercise discretion, performing duties which are not necessarily explicitly covered by the law, and qualified immunity does cover these situations.
Second, it must be determined if a reasonable person would have known that an action violated the law and abridged someone's civil rights. It may be the case that an activity is illegal, but that a government official could not reasonably have known that because the law is obscure or for some other reason. If a government official knew that an activity was illegal or should have known and does it anyway, that official is liable.
While individuals may be protected under qualified immunity, the government itself can still be liable for civil suits in cases in which civil rights are violated. Such suits protect the rights of individuals, and they can also be used to establish precedents. These precedents will in turn shape the way in which officials perform their duty in the future, reducing the number of legally nebulous situations which could potentially result in violations of civil rights.
This legal doctrine is designed to ensure that the rights of citizens are protected while also facilitating the ability of officials to perform public duties. Public officials could be limited if they could only act in situations in which there was a clear and established law, and if they could potentially be sued for using their discrimination in a given situation. Under this doctrine, clear violations of the law such as abuses of power are not protected, ensuring that, while public officials can act on their own discretion, they do not have carte blanche to do as they please.