BMW M GmbH, formerly known as BMW Motorsport GmbH, is a subsidiary of BMW AG that manufactures High-performance luxury cars.
BMW M was initially created to facilitate BMW's racing program, which was very successful in the 1960s and 1970s. From Wikipedia