The federal government has the power to create a military force to defend the country. The Uniform Code of Military Justice is the primary body of military law, laying out the rights and rules governing those serving in the military. The code covers issues such as officers' right to discipline soldiers and to apprehend and detain law violators.

The code also details the process for military courts-martial, a military tribunal that hears matters related to military service, such as desertion or treason. The code outlines what punishments a military court can pronounce, as well as the right to appeal. Military law attorneys can help prosecute or defend troops court-martialed in cases of discipline or disobedience of a lawful command.