When the Germans realized they were being outgunned because they had no semi-automatic infrantry weapon, they commissioned Walther and Mauser to design one.  The problem was that the Germans  were very big on bullet ballistics and did not want to bleed gas out of the barrel through a port because it would reduce the muzzle velocity of the bullet.

So, the design had to capture the gas pressure AFTER the bullet left the muzzle.  This meant having a gas cylinder on the muzzle.  Probably 10,000 guns were contracted for each by Walther and  Mauser.  The Mauser design was patterned after the K98k and did not work well.  Walther's design, although not terribly successful, was much better than Mauser's so, even before Walther completed their trial guns contract, they were given the military contract to build their design.  Walther had only made about 7,600 trails guns at that point.  Walther was not a heavy duty rifle manufacturer so a second contract was let to Berlin-Lubecker.  Mauser went on to make about 13,000 trials guns.  This was in excess of the possible 10,000 initial contract but that could have been a matter of needing to make more to come out financially on the contract.  No one seems to know details about this.  

I would like to clear up a point of confusion about the designation of these guns.  Mauser's was a G.41(M).  The "M" in parentheses meant that it was a Mauser trials gun.  Walther initially had a designation of G.41(W) on their guns.  The "W", likewise, meant it was a Walther trails gun.  When Walther got the regular military contract they then dropped the "W" from the code and stamped them simply G.41.  Lubecker did the same.  When I see the designation "G.41W", since most misuse it, I am never sure what they are talking about unless they include a serial number.   A G.41(W) is a trials gun and very scarce to rare since they worked reasonably well and were quickly used up.  A G.41 is a regular military contract gun and can be made by Wather (ac code) or Berlin-Lubecker (duv code).