The blaze started late on Friday night at Burro Canaglia Resto, an Italian restaurant in the central neighbourhood of Salamanca.
An eyewitness told El Pais newspaper that the fire started after a waiter was flambeing a dish and the flames set fire to the ceiling and walls.
Diners struggled to flee as the blaze started near the main exit, emergency services said.
Spanish police are investigating the cause of the fire.