The origin of this rifle can be traced back to the final years of World War II when Mauser engineers at the Light Weapon Development Group (Abteilung 37) at Oberndorf am Neckar designed the MKb Gerät 06 (Maschinenkarabiner Gerät 06 or "machine carbine device 06") prototype assault rifle chambered for the intermediate 7.92×33mm Kurz cartridge, first with the Gerät 06 model using a roller-locked short recoil mechanism originally adapted from the MG 42 machine gun but with a fixed barrel and conventional gas-actuated piston rod. It was realized that with careful attention to the mechanical ratios, the gas system could be omitted. The resultant weapon, the Gerät 06H (the "H" suffix is an abbreviation for halbverriegelt or "half-locked") was assigned the designation StG 45(M) (Sturmgewehr 45(M) or assault rifle) but was not produced in any significant numbers and the war ended before the first production rifles were completed.
The German technicians involved in developing the StG 45(M) were taken to work in France at CEAM (Centre d'Etudes et d'Armement de Mulhouse). The StG 45(M) mechanism was modified by Ludwig Vorgrimler and Theodor Löffler at the Mulhouse facility between 1946 and 1949. Three versions were made, chambered in .30 Carbine, 7.92×33 mm Kurz as well as the experimental 7.65×35 mm French short cartridge developed by Cartoucherie de Valence in 1948. A 7.5×38 mm cartridge using a partial aluminium bullet was abandoned in 1947. Löffler's design, designated the Carabine Mitrailleuse Modèle 1950, was retained for trials among 12 different prototypes designed by CEAM, MAC, and MAS. Engaged in the Indochina War and being the second NATO contributor, France canceled the adoption of these new weapons for financial reasons.
In 1950, Vorgrimler moved to Spain where he created the LV-50 rifle chambered for the Kurz cartridge and later, the proprietary 7.92×40 mm CETME M53 round. At this point, the rifle was renamed the Modelo 2. The Modelo 2 drew the attention of the West German Border Guards (Bundesgrenzschutz), who sought to re-equip the newly formed national defense forces. Not willing to accept a cartridge outside of the NATO specification, the Germans asked CETME to develop a 7.62×51 mm version of the rifle. The resulting CETME Model A was chambered for the 7.62×51 mm CETME cartridge which was identical in chamber dimensions but had a reduced-power load compared to the 7.62 mm NATO round. Further development of the rifle with input from H&K produced the CETME Model B which received several modifications, including the ability to fire from a closed bolt in both semi-automatic and automatic firing modes, a new perforated sheet metal handguard (the folding bipod had been the foregrip in previous models), improved ergonomics and a slightly longer barrel with a 22 mm rifle grenade launcher guide. In 1958, this rifle was accepted into service with the Spanish Army as the Modelo 58, using the 7.62×51 mm CETME round.
In 1956, the Bundesgrenzschutz canceled their planned procurement of the CETME rifles, adopting the Belgian-made FN FAL (G1) instead. However, the newly formed West German Army (Bundeswehr) now showed interest and soon purchased a number of CETME rifles (7.62×51 mm NATO chambering) for further testing. The CETME, known as the Automatisches Gewehr G3 according to German nomenclature, competed successfully against the Swiss SIG SG 510 (G2) and the American AR-10 (G4) to replace the previously favored G1 rifle. In January 1959, the Bundeswehr officially adopted the CETME proposal. The West German government wanted the G3 rifle to be produced under license in Germany; purchase of the G1 had previously fallen through over FN's refusal to grant such a license. In the case of the G3, the Dutch firm Nederlandse Wapen en Munitiefabriek (NWM) held production and sales rights to the CETME design outside of Spain. To acquire production rights, the West German government offered NWM contracts to supply the German Air Force (Luftwaffe) with 20mm ammunition. Production of the G3 was then assigned to Rheinmetall and H&K. The latter company already had ties to CETME, and had worked to further optimize the CETME rifle for use with the full-power 7.62×51 mm NATO cartridge (as opposed to the downgraded CETME variant). In 1969, Rheinmetall gave up production rights to the G3 in exchange for H&K's promise not to bid on MG 3 production. Later in 1977, the West German government ceded ownership of G3 production and sales rights exclusively to H&K.
Initial production G3 rifles differed substantially from more recent models; early rifles featured closed-type mechanical flip-up sights (with two apertures), a lightweight folding bipod, a stamped sheet steel handguard, a wooden buttstock (in fixed stock models) or a telescopic metal stock. The weapon was modernized during its service life (among other minor modifications it received new sights, a different flash suppressor, and a synthetic handguard and shoulder stock), resulting in the most recent production models, the G3A3 (with a fixed polymer stock) and the G3A4 (telescoping metal stock). The rifle proved successful in the export market, being adopted by the armed forces of over 40 countries. The G3 was and in some cases continues to be produced under license in: France (MAS), Greece (Hellenic Arms Industry), Iran (Defense Industries Organization), Luxembourg (Luxemburg Defense Technologie), Mexico, Myanmar, Norway (Kongsberg Våpenfabrikk), Pakistan (Pakistan Ordnance Factories), Portugal (FBP), Saudi Arabia, Sweden (FFV), Thailand, Turkey (MKEK) and the United Kingdom (Royal Ordnance).