Stainless steel is a steel alloy that contains a high percentage of chromium (greater than 10.5% by weight). Unlike ordinary carbon steels, it has good resistance against corrosion and rusting. This is because of the high chromium content. What happens is that the chromium at the surface of the object reacts with the oxygen in the air, to form a thin layer of chromium oxide. This chromium oxide layer prevents oxygen from reaching the inner steel and therefore blocks rusting and corrosion. It must be remembered that while stainless steel is rust-resistant, it is not rust-proof.
Fittingly, the invention of stainless steel was actually related to firearms. Harry Brearley, an English chemist was working in Sheffield, England for Brown Firth research labs in 1912, trying to find a new steel that could resist erosion caused by high temperatures of gun barrels. It was already known at that time that adding a little chromium to steel increases the melting point of steel. He was trying to establish precisely, the relationship between melting points and chromium content of various steel samples. As part of this study, he was required to study the microstructure of the various steel alloy samples and to do this, he had to polish and etch the samples first. The standard way to do this was to use a weak solution of nitric acid and alcohol to do the etching, but as Mr. Brearley found, some of the samples were exceptionally resistant to these chemicals. After a bit of investigation, he determined that the high chromium content of these samples was responsible for the exceptional resistance to acid. From this research, a whole new industry of manufacturing stainless steels sprung up around the Sheffield area.
Like chrome-moly steels, there are also different grades of stainless steels and only some grades are used in the manufacture of firearms. For instance, SAE grades 410 and 416 are used for firearms barrels. They are both steel alloys with high chromium content (11.5 - 13.5% for 410 stainless steel and 12-14% for 416 stainless steel). The main difference is that 416 stainless steel contains a bit more sulfur in it, which makes it easier to machine than 410 stainless steel, which makes the barrels cheaper to produce. However, 410 stainless steel retains its toughness better and performs better in freezing conditions. Some companies make custom alloys, such as Crucible Specialty Metals' 416R, which is specially designed for precision steel barrels. Another stainless steel alloy used by some makers is 17-4 PH (PH standing for Precipitation Hardening).
Some of the other parts of the guns are also made of 400 or 300 series of stainless steels. The 300 series is more resistant to corrosion than the 400 series of steels, but cannot be hardened as easily, so it is used for parts that aren't exposed to huge forces.
The advantage of stainless steel alloys over chrome-moly steel alloys is that they are easier to machine and resist heat erosion better. However, they are a bit more expensive and cannot be blued using conventional methods. The US military prefers chrome-moly barrels, but most competitive target shooters prefer stainless steel barrels, because they can be machined more precisely and keep their accuracy longer. This is why the majority of match-grade barrels are made of stainless steel.