The Supreme Court of the United States ruled this in DC vs Heller
The Second Amendment protects an individual right to possess a firearm unconnected with service in a militia, and to use that arm for traditionally lawful purposes, such as self-defense within the home.
The Amendment’s prefatory clause announces a purpose, butdoes not limit or expand the scope of the second part, the operativeclause. The operative clause’s text and history demonstrate that itconnotes an individual right to keep and bear arms.
The prefatory clause comports with the Court’s interpretation of the operative clause. The “militia” comprised all males physicallycapable of acting in concert for the common defense. The Antifederalists feared that the Federal Government would disarm the people in order to disable this citizens’ militia, enabling a politicized standing army or a select militia to rule. The response was to deny Congress power to abridge the ancient right of individuals to keep and beararms, so that the ideal of a citizens’ militia would be preserved.
http://www.supremecourt.gov/opinions/07pdf/07-290.pdf
Title 10 Chapter 13 of the USC defines the militia
(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.
http://uscode.house.gov/download/pls/10C13.txt
DC vs Heller states that the 2nd Amendment isn't unlimited:
Like most rights, the Second Amendment right is not unlimited.It is not a right to keep and carry any weapon whatsoever in any manner whatsoever and for whatever purpose: For example, concealed weapons prohibitions have been upheld under the Amendment or state analogues. The Court’s opinion should not be taken to castdoubt on longstanding prohibitions on the possession of firearms byfelons and the mentally ill, or laws forbidding the carrying of firearms in sensitive places such as schools and government buildings, or laws imposing conditions and qualifications on the commercial sale of arms. Miller’s holding that the sorts of weapons protected are those “in common use at the time” finds support in the historical traditionof prohibiting the carrying of dangerous and unusual weapons.
http://www.supremecourt.gov/opinions/07pdf/07-290.pdf