There is a bit of a grey area, as homeschooling is not explicitly forbidden in Spanish legislation. There is an obligation that children between the ages of 6 to 16 receive an education. In the Spanish Constitution Freedom of Education is recognised, but on the other hand, there are no national regulations for Homeschooling in place.
Some parents have obtained special permission for their child to enter into a Home Learning plan combined with high level sports education for example, which would make it impossible to attend regular schools.
There are cases of people getting fined for homeschooling, mostly when kids have been taken out of school and the school did not agree and denounced the parents. There are also cases of parents having obtained the cooperation of the local school, and those who never registered their children in the Spanish school system.
There is an organisation ¨Libre Educación´ that offers information on all aspects and how to do it as legally as possible.
Alternatively, you can arrange for ´distance learning´ through a government approved institute, they offer courses for Primaria and Secundaria education online, you can sit the exams in Spain or abroad.
More info