Selective conscientious objection
Selective conscientious objection is the practice of refusing some, but not all, military service. It is much more controversial than blanket conscientious objection based on consistent pacifism. Views on selective conscientious objection range from being morally impermissible, morally permissible, a right that may be exercised, or morally obligatory in the case of military personnel asked to fight an illegal war of aggression. Arguments for and against
The traditional view is that soldiers are obligated to obey superior orders to participate in a war, even when this is against their conscience. The moral culpability for fighting an unjust war, in this view, is visited entirely on the leaders and not on ordinary soldiers who are entirely innocent (see moral equality of combatants). Arguments for this view include those based on social contract theory which posit that citizens should obey their state's decision to go to war, the argument that individual soldiers are ill-placed to determine whether a war is just. In 1539, Francisco de Vitoria argued: 
Those who reject the moral equality of combatants regardless of whether they are fighting for a just or unjust cause argue that individual soldiers have an obligation to refuse to fight an unjust war if they can do so without suffering death or other grave harms. John Rawls argues that selective objection should be allowed as it may prevent the government from continuing an unjust war. Historical examples
During the first several years of the United States participation in the Vietnam War, selective conscientious objection based on just war theory was widespread among Catholic war resisters as well as Jews, nonreligious men, and those of other faiths. Despite its strong grassroots support, selective conscientious objection was unacceptable to the state as it was feared that allowing conscripts to pick and choose what wars they would fight in would undermine national defense. During the 2022 Russian invasion of Ukraine, some leaders including the president of Ukraine and president of Estonia argued that Russian soldiers should selectively object to the invasion. Many Israelis who refuse to serve in the IDF are selective conscientious objectors who criticize certain actions such as the invasion of Lebanon or occupation of the West Bank as immoral or illegal. Legal recognition
Legally, courts in most countries have distinguished between blanket objection and selective objection, allowing only the former. Soldiers have a right and a responsibility to refuse to commit war crimes, but the right to refuse to fight an illegal war is not widely recognized. In the United States, the 1971 Gillette v. United States found that to be recognized as a conscientious objector, one must refuse all wars. International law scholar Tom Dannenbaum argues that soldiers should have a right not to fight in illegal wars, and those who refuse to should be recognized as refugees. References

Conscientious objection
Anti-war movement
Military ethics
Civil disobedience