The stunning i8 hybrid sports car is just one of several all-new BMWs due this year. Photo credit: BMW.

German luxury-car giant BMW (BAMXF -3.91%) reported a surprise fourth-quarter-profit gain on Tuesday, thanks to increasing global demand for its compact luxury offerings.

BMW said that it earned 1.95 billion euros ($2.7 billion) before interest and taxes, up from 1.87 billion euros in the year-ago quarter -- and well ahead of the 1.83 billion euro Wall Street estimate, according to Bloomberg. 

Sales booming, but so is spending
"In 2013 we achieved new highs for sales volume and profit," BMW Chairman Norbert Reithofer said in a statement on Thursday. "We forecast further sales volume growth in the current year which will again bring us a new all-time high" of more than 2 million vehicles," he said.

BMW is in a tight global sales race with German rivals Audi and Mercedes-Benz. Audi's corporate parent Volkswagen (VWAGY 0.67%) is making a massive push to become the world's largest-selling automaker by 2018, while Mercedes' parent Daimler (VWAGY 0.67%) is looking to overtake BMW in global sales by 2020.

That pressure has led BMW to boost its investments in advanced technology and new production facilities, part of its own long-term plan to stay ahead of rivals. A big part of that plan focuses on China, where BMW has trailed Audi in the country's white-hot luxury-vehicle race.

A strong luxury market is drawing lots of competition
While BMW expects sales to break 2 million in 2014, it has also said that its spending will continue to be heavy this year -- coming on top of the 4.8 billion euros it invested in 2013.

BMW's X3 has seen strong sales gains so far in 2014. Photo credit: BMW.

Luxury vehicles are much more profitable than mass-market cars, and the global market for luxury vehicles is growing more rapidly than the overall market. Those conditions are drawing a lot of competition -- far more than BMW's traditional German rivals.

Fiat Chrysler (NASDAQOTH: FIATY) is believed to be planning a major push into BMW territory with its Maserati and Alfa Romeo brands. Tata Motors (TTM), the Indian automaker that owns Jaguar and Land Rover, is working on several new models, including a family of compact Jaguars to rival BMW's 3-Series.  

Meanwhile, General Motors (GM 4.37%) is in the midst of a massive overhaul of its Cadillac brand, with an eye clearly focused on gaining significant market share in China. And Nissan (NSANY -0.14%) is making similar moves with its Infiniti brand, likewise drawn by the potential of the booming Chinese market for luxury vehicles.

BMW has held its ground well, but the fight continues
Long story short, given competitive pressures and its heavy investment cycle, BMW did well to post a profit increase in the quarter. Despite heavy spending, BMW's automotive profit margin remained solid at 9.4%, though it trails Audi's 10.1%.

That situation is likely to continue for a while. BMW is a much smaller company that the mighty Volkswagen Group -- yet it has to invest to keep pace with VW's investments in Audi. BMW's products continue to be excellent and its sales continue to be strong, but competition -- and the need to invest to stay ahead -- could keep margins, and profit growth, muted for a while.