Volkswagen has stolen Toyota's crown to become the world's top carmaker by sales -- at least for the year so far.

Data on vehicles sold by the companies during the first six months of 2015 show the German automaker nudged out its Japanese rival to claim the top spot.

Volkswagen (VLKAF) sold 5.04 million vehicles from January to June, a slight dip from a year earlier. That compares to 5.02 million sold by Toyota (TM) over the same period. Group sales dropped 1.5% due to a weaker performance by its Toyota and Daihatsu brands.

Automakers are being challenged by softening conditions in markets like China and Russia, and Volkswagen is cautious about the outlook.

The carmaker, which also owns the Audi (AUDVF) and Porsche (POAHY) brands, described its performance so far this year as "satisfactory" in a difficult environment.

Sales director Christian Klingler has warned specifically about tough market conditions in China.

Related: Will China's slump sink Europe's recovery?

Sales in China -- Volkswagen's largest single market -- dropped nearly 4% in the first half of the year. North America was brighter, where sales climbed 6%.

Toyota also increased production in the U.S. But it's faced other challenges in recent months.

Toyota is among a number of auto firms swept up in a massive recall over possibly faulty airbags. The automaker has recalled millions of vehicles globally on fears Takata airbags installed may explode and send shrapnel flying at drivers and passengers.