The so-called eCall device will automatically alert the nearest emergency centre in the event of a crash by calling the EU-wide emergency number 112, which will give authorities information such as the exact location and time of the crash and the number of passengers in the vehicle.
Members of the European Parliament in Strasbourg approved the law on Tuesday, meaning car manufacturers such as Volkswagen and Volvo would have to ensure all passenger cars and light commercial vehicles are fitted with the devices by March 31, 2018.
The vote was welcomed by the auto industry.
"This decision brings Europe one step closer to making operational a system which we have been advocating since 2004," said Erik Jonnaert, secretary general of the European Automobile Manufacturers' Association which includes companies such as BMW, Fiat and Daimler.
Road accidents killed 25,700 people in the EU last year.
The European Commission, which proposed the law, estimates that the emergency response time will halve in the countryside and fall 60 percent in urban areas.
People would also be able to make an eCall by pushing a button inside the car, giving witnesses a chance to report accidents.
The devices will not track vehicles outside emergencies and authorities will not be able to transfer the data to third parties without the explicit consent of the person concerned.
But some members of the European Parliament said the proposal did not go far enough to protect drivers' privacy and did nothing to prevent accidents.
"Just putting in the infrastructure for this would eat up a huge chunk of the road safety budget, yet it will not prevent a single crash," said Vicky Ford, a Conservative MEP.
Three years after the launch, the Commission will assess whether eCall devices should also be fitted onto buses, coaches and trucks.
© Thomson Reuters 2015