Osasuna and Real Valladolid were relegated from the Primera Division on a dramatic closing day of the season.