From tomorrow, between 0530 GMT and 2000 GMT, "vehicles with even-number registration plates will be allowed to drive around on even-number days and cars with odd-number registration plates on odd-number days," it said in a statement.
The measure, which will be re-evaluated on a daily basis depending on pollution levels, is a first in Spain.
It is activated when levels of harmful nitrogen dioxide in the atmosphere go above 200 microgrammes per cubic metre in at least two measuring stations for two days running, and if the air is unlikely to clear imminently.
Buses, taxis and emergency vehicles are also exempt.
More From This Section
"It's not about traffic restrictions but about the important issue of public health," Deputy Mayor Marta Higueras told reporters.
"Lots of people suffer from breathing problems and are very affected by pollution."
With 3.2 million residents and some 1.8 million cars, Madrid often suffers from bad bouts of pollution.
The move to ban half of cars off the roads is level three out of four anti-pollution measures.
Level four also bans taxis from the city, bar those using hybrid cars.
Inigo Henriquez de Luna, PP spokesman in Madrid's local parliament, slammed it as "ideological" and said authorities should do more to encourage residents to avoid using their cars rather than punish them.
The anti-pollution measures were implemented by former PP mayor Ana Botella just before municipal elections in May 2015.