Spain will grant residency and work permits to about 300,000 migrants living in the country illegally each year for the next three years, the country's migration minister said Wednesday.