BERLIN—A group of German auto makers agreed to pay slightly more than €2.5 billion ($2.7 billion) for Nokia’s digital mapping service, prevailing over Silicon Valley bidders in a battle for a key enabling technology for self-driving cars.

German luxury car makers Audi, a unit of Volkswagen AG, Mercedes-Benz parent Daimler AG, and BMW AG have agreed in principle to purchase the telecommunications group’s digital mapping service Nokia Here, according to a person familiar with the situation.

...