A short circuit was probably to blame for the fire
No one is believed to have been inside but firefighters say the entire structure is now at risk of collapsing.
The fire was put out on Sunday evening, but officials say the building's skeleton could have been weakened by the high temperatures.
Businesses and offices are to remain closed and transport has been diverted.
Large pieces of the Windsor Building plunged to the ground as the blaze destroyed its top floors, sending columns of black smoke into the night.
Nearby bars, nightclubs and blocks of flats were evacuated as flames ripped through the building, one of the capital's most emblematic structures.
A spokesman for the fire services said the building in the business heart of Madrid was empty when the fire started.
He said no civilians had been injured, but three firemen were being treated for smoke inhalation.
Short-circuit theory
Several top floors have slumped onto lower ones, and Madrid fire chief Javier Sanz told local radio the 106m (350ft) tall building was still unstable.
"It is clear the structure has been damaged and has suffered high temperatures, and we cannot be certain that a pillar, girder or some other structural element will not collapse," he said.
The fire was put out shortly after 2000 (1900 GMT). Officials said the next 48 hours would be crucial in determining whether the structure would fall.
An investigation has been opened. Spanish media said the fire appeared to have been an accident.
Madrid Mayor Alberto Ruiz Gallardon said the fire is believed to have been caused by a short-circuit on the 21st floor.
"This is the biggest fire ... this city has ever had," he told the Associated Press news agency on Sunday afternoon.
For safety reasons, he said businesses and offices would remain closed until at least Wednesday.
Traffic around the area will be diverted and underground train services passing by the tower will be curtailed.
Prime Minister Jose Luis Rodriguez Zapatero visited the scene on Sunday.
He said: "I wanted to thank all those people who have been working since early in the morning - firefighters, police and all those who have thrown themselves in to help in this catastrophe."
The ruins of the Windsor tower.
The 32-story Windsor Tower, located in the business district of Madrid, Spain, was devastated by the largest fire in the city's history.

The fire destroyed large parts of the building, completely gutting the top 14 floors. Parts of the structure collapsed during the blaze, which was extinguished on Sunday evening. 

The 106m high tower is now extremely unstable, and experts believe there is a chance it could collapse in the next 24 hours. Surrounding areas have been evacuated, traffic diverted, and trains stopped on the three subway lines beneath the building.

The fire is believed to have been started by an electrical short-circuit on the 21st floor. No-one was in the building (which was undergoing refurbishment) at the time of the blaze; the only casualties being three firefighters treated for smoke inhalation.

The top twenty floors of the building housed the Deloitte & Touche auditing firm. The remains will be demolished at a future date.