The easiest way to to get to your destination is a direct flight. Direct flights for from San Sebastian to Madrid are offered by:
Aviasales.ge suggests buying tickets for San Sebastian – Madrid in advance in order to choose the conditions for your flight that best suit your preferences and budget.
Also view:
San Sebastian airports serving flights to Madrid:
Madrid airports accepting flights from San Sebastian: