The strike was launched by unions representing workers who clean the city's streets and public gardens on November 5 in protest against plans to slash 1,134 jobs out of a total of around 7,000, and cut salaries by up to 40 percent.
In meetings on Sunday afternoon, workers approved a deal reached earlier by unions and the private companies that employ the cleaners, the CCOO labour union said in a statement.
"The workers approved the agreement by an absolute majority and agreed to call off the strike," it said.
"They will resume normal service on the night shift" on Sunday to Monday, the union added.
Under the deal hammered out in marathon talks over the weekend, the companies agreed not to fire any workers in return for the employees accepting temporary unpaid lay-offs.
Before the strike, the companies, which include OHL-Ascan, FCC and Sacyr-Valorisa, had said cuts were necessary since the city hall, under pressure to reduce costs like public authorities around Spain, was spending less on cleaning.
The strike did not include the refuse collectors who remove bags of domestic rubbish, but even so it left piles of waste paper and other street trash blocking pavements in this city of three million people.
"The excessive and unjustifiable intentions of the companies, along with the irresponsible and deplorable management of the conflict by the city hall, have led Madrid to undergo a situation that neither workers nor citizens should have suffered," the CCOO said.
A public company had started cleaning the streets on Saturday on the orders of the mayor of Madrid, Ana Botella, in the absence of a deal to end the strike earlier.