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. [Article II of the U.S. Bill of Rights]
As the U.S. Supreme Court ponders the never ending debate about gun control in the Washington DC vs Heller case, it should be noted that the Second Amendment is far from being the puzzling and ambiguous riddle that so many have often claimed. The Founders' usage of terms within it, its Bill of Rights context, and the historical details regarding its development make perfectly clear what the amendment's meaning is.
There is an overall goal clearly stated in the first clause of the Second Amendment, "the security of a free state," which is routinely ignored when discussing it. The "free state" reference is actually taken from the first American state bill of rights, that written by George Mason for Virginia in 1776. In fact, the well regulated militia reference was also based directly upon that Revolutionary Era source.
Virginians of 1776 were contending against tyranny. The British claimed unlimited authority and utilized paid forces (a standing army) to enforce their claims. Many of those in Virginia had self-organized previously for defense against British tyranny. George Mason, along with other patriots like Patrick Henry, helped organize county level defensive associations that included all the able-bodied men to defend against British officials and troops in 1774 and 1775. Well before hostilities, Mason referred to this self-embodying armed association as a well regulated militia. The reason for this description was because the men brought their own arms, self-organized into companies, picked their own officers, and trained themselves as an effective defensive force. The "well regulated" language means effective or proficient, which is standard period usage. Well regulated has nothing to do with government regulation as gun control advocates routinely assert. The government constituted the threat that Virginians needed to protect themselves against because government officials and their paid forces were violating the constitution and the people's rights.
There is a three part structure with leading Second Amendment language found in EVERY state bill of rights extant when the Constitution was written. George Mason prepared the very first of these as part of Virginia's Bill of Rights, and every subsequent state copied it. Thus, it has been dubbed the Mason Triad in honor of its first bill of rights author. The state bill of rights Mason Triads always lead with Second Amendment related language, either a well regulated militia reference or the people have a right to bear arms language. The second part always indicated a standing army is dangerous to liberty, and the final third stated that the military will be under the control of the civil power. Restating this in more modern terms, the Mason Triads recognized a defensively effective armed civil population, warned of the danger to liberty from paid government forces, and indicated the latter would be under the control of the former.
The first person to utter the words "Bill of Rights" in relation to the U.S. Constitution was none other than George Mason. He did so in the 1787 Federal Convention where the U.S. Constitution was written. Mason pointed out that there was no bill of rights in what had been prepared as the U.S. Constitution, and that the state bills of rights were no security because the laws of Congress were expressly stated to be paramount to the state constitutions that the state bills of rights were part of. Mason's suggestion for a bill of rights based on the state bills of rights was voted down. As a result, Mason refused to sign or support the Constitution and became the document's most influential opponent.
Mason worked long and hard for a U.S. Bill of Rights. He influenced everyone he came into contact with to accept his view that the Constitution was fundamentally defective without one, and he was successful. During the first few days of the Virginia Ratifying Convention in June of 1788, Mason prepared a complete Bill of Rights for the U.S. Constitution. He based this directly on the 1776 Virginia Bill of Rights with added provisions from other states' bills of rights. His Mason Triad for the Virginia Ratifying Convention was the first to include both well regulated militia language and right to bear arms language together as the lead provision. This Mason 1788 proposed Bill of Rights became the model for all four of the last state ratifying conventions.
What James Madison promised to support in the 1788 Virginia Ratifying Convention in order to obtain ratification of the Constitution was the Bill of Rights written by George Mason. What Madison took to Congress was his version of the Mason Bill of Rights that all of the last conventions of 1788 had adopted.
One final point. "Militia" was universally understood as a reference to all able-bodied men (other than slaves). Mason's view was that the militia consist of the whole people. Thus, the well regulated militia reference of the Second Amendment is an indication that a defensively effective self-embodying militia of the able-bodied men is necessary to the security of a free state. The only way to assure this against abuse of government power is to guarantee private rights, with the strongest possible period language. That is why the right of the people to keep and bear arms shall NOT be infringed.