The United States Military Aircraft Designation System was first designed in 1919 when the US Army's Aeronautical Division became the United States Army Air Service. Before this aircraft were put into service under their manufacturers' designations.
During this period Type Designations used by the United States Army Air Service were allotted, using two or three letters, which were an abbreviation of the aircraft's purpose. Examples include GA for Ground Attack aircraft; NO for Night Observation aircraft and NBS for Night Bombardment, Short Distance aircraft.
From 1924 to 1947 the Air Service, United States Army Air Corps, United States Army Air Forces and United States Air Force used a designation system based on mission category, with each model in a category numbered sequentially. In 1947, the designation system was extensively overhauled, with several categories being dispensed with, and others renamed. For instance, the Lockheed P-80 Shooting Star (Pursuit) was redesignated as F-80 (Fighter), while the A-26 medium bomber/attack aircraft was redesignated as the B-26, reusing the designation, the Martin B-26 having retired in the meantime.
From 29 March 1922 to 18 September 1962 the United States Navy (including United States Marine Corps and United States Coast Guard) used a completely separate designation system, based on both mission and manufacturer.
From 1956 to 1962 the United States Army used a separate designation system from that of the United States Air Force.
Since 18 September 1962 a joint system of mission-based designations has been used, with most of these restarting from 1. Various previously-designated models from the pre-1962 Army-Air Force system (such as the F-111) were not redesignated.
All in-use USN/USMC aircraft from the pre-1962 system were redesignated within the new system. An attempt was made to retain the original Type Sequence numbers for as many aircraft as possible. Thus, the F2H Banshee became the F-2, the F4H Phantom II became the F-4 and the F8U Crusader became the F-8.
In the US Air Force, these designations are commonly referred to as "Mission Design Series" or MDS. In the US Navy, US Marine Corps and US Coast Guard, they are referred to as Type/Model/Series or T/M/S.
A comprehensive explanation can be found at Systems of Designation.