Qualified immunity protects public officials from being sued for damages unless they violated “clearly established” law of which a reasonable official in his position would have known. It aims to protect civil servants from the fear of litigation in performing discretionary functions entrusted to them by law.
The qualified immunity test requires a two-part analysis: "(1) Was the law governing the official's conduct clearly established? (2) Under that law, could a reasonable officer have believed the conduct was lawful?" Government officials performing discretionary functions generally are shielded from liability for civil damages as long as as their conduct does not violate clearly established statutory or constitutional rights of which a reasonable person would have known.