The "BiciMad" service follows similar schemes in Spanish cities such as Barcelona, as well as Paris's "Velibs" and London's so-called "Boris bikes".
"In the first phase, 1,500 bicycles will be provided and they will all be electric," distributed across 120 bike stands, a Madrid city hall spokeswoman told AFP.
Spanish firm BonoPark has got the 25-million-euro ($35 million) contract to build the parking stands and install the bikes, equipped with electric motors that help propel them when pedalled.
It has yet to be confirmed how much users will have to pay for the use of the bikes.
The northern Spanish city of San Sebastian already has electric shared bikes, but the scheme is a first for Madrid, where cycle lanes are relatively scarce.
The city hall said BiciMad is part of an 884-million-euro traffic management scheme which will create some 60 kilometres (37 miles) of cycle lanes in Madrid's streets.