I recently visited Madrid for the first time in 10+ years. I intentionally left our itinerary very loose to allow for lots of exploring and eating. Because Madrid is so wonderfully walkable, in between visits to the outstanding museums, we filled our days discovering charming little spots to sit, enjoy a beer and some tapas and pinxtos.
I became mildly obsessed with one pinxto in particular, called a gilda. It's a skewer of vinegary little peppers, anchovies and green olives. I had my first gilda on our first night in Madrid at Bosco de Lobos, and I think theirs are still my favorite. I did recreate gildas at home the week of our return (thanks to wonderful ingredients and wine from Despana: http://www.despanabrandfoods.com), along with a tortilla Española
Technically Bosco de Lobos is an Italian restaurant, but there is plenty of Spanish influence here, and the space is spectacular, located within the Madrid Architects Association (http://encompaniadelobos.com/boscoMadrid.html). Other favorite spots were Celso y Manolo and Taberna La Carmencita (https://tabernalacarmencita.wordpress.com), all located in the Chueca neighborhood of Madrid.
Also in the Chueca and not to be missed is the Mercado de San Antón, a beautiful marketplace that includes several stalls where you can purchase prepared foods and drinks and enjoy in a fun communal atmosphere. There are a few bars and restaurants (including some on the rooftop) that offer table service for lunch and dinner.
On the same trip, we also traveled to Rioja and Bilbao -- look for a post on that wonderful adventure in food and wine soon on A Curious Palate.