A writ petition is a legal remedy filed before the High Court or Supreme Court for the enforcement of fundamental or legal rights. It can be filed when a person believes that a government authority or public body has acted unlawfully, violated rights, or failed to perform its legal duties.