Mata opened the scoring from the penalty spot in the 20th minute and restored their lead in the 83rd after Adnan Januzaj had levelled in the second half for Sociedad, who are also bidding to qualify for Europe's elite competition.
The victory took Getafe into fifth place in the standings on 52 points, two behind Sevilla who occupy the final Champions League qualifying spot in fourth.
Ramos' Real exit truly an end of an era - The Warm-Up
Sociedad, meanwhile, slumped to a fourth successive defeat and were left seventh in the table on 47. (Reporting by Richard Martin Editing by Christian Radnedge)
‘Danish will be even more motivated’ – Lukaku on facing Eriksen’s Denmark team
'We made too many mistakes' - Switzerland coach Petković on 3-0 loss to Italy