Madrid is the capital and largest city of Spain.
It’s kind of obvious, however, I’m not so surprised hearing that someone thinks that Barcelona is the capital of Spain. At the end, Barcelona is the capital of Catalonia and very famous tourist destination.