Yes you can and this is known as Pluriactividad. Information from the social security WEBSITE.
You will need to set up as Autonomo by registering with the social security and the Tax Office. You may need to employ a gestor de contabilidad to carry out your quarterly IVA and tax declaration.
If you have a full time employment contract and you haven´t been registered as self employed in Spain before, you can get substantial discounts on the Autonomo contributions during the first 36 months of your ´pluriactividad´, ranging from 25 to 50%. Discounts for part time workers as well, but smaller – 15 to 25%. The ´Tarifa Plana´ is available for first time Autonomo´s in ´pluriactividad´ as well, you will have to choose what ´scheme´ is most beneficial to you. More info on that in our Library, Employment section.
How does that work in practice? You will pay social security contributions in both ´regimes´ and are entitled to a refund, but only if the total of your contributions exceeds 12.739,08 euros, 50% of the excess paid.
If you pay Autonomo based on the minimum ´base regularadora´ this would mean that your wages must be at least 2.670 euros/month to reach this amount.
You don´t have to apply for the refund, the INSS should pay it out before the 1st of May of the following year. You can follow the progress of the devolution due on the Electronic Office of their website and also apply for the refund if you didn´t receive it. You can only apply in the window Jan 1 – April 30, so don´t leave it too long or you will have to wait another year.
If you can´t access the electronic office, you will need to apply in person, at the INSS office in your area.