FIRST
there was the United States Constitution
Article I - Section 8 - which says:
"The congress shall have power to:
...provide for organizing, arming, and disciplining, the militia, and for governing such part of them as may be employed in the service of the United States, reserving to the states respectively, the appointment of the officers, and the authority of training the militia according to the discipline prescribed by Congress..."
THEN AFTERWARDS
came Amendment II - which says:
"A well regulated militia, being necessary to the security of a free state, the right of the people to keep and bear arms, shall not be infringed."
U.S. Code - TITLE 10 - Subtitle A - PART I - CHAPTER 13
Paragraph 311 - Militia: composition and classes
(a) The militia of the United States consists of all able-bodied males at least 17 years of age and, except as provided in section 313 of title 32, under 45 years of age who are, or who have made a declaration of intention to become, citizens of the United States and of female citizens of the United States who are members of the National Guard.
(b) The classes of the militia are
(1) the organized militia, which consists of the National Guard and the Naval Militia; and
(2) the unorganized militia, which consists of the members of the militia who are not members of the National Guard or the Naval Militia.