The rank of a scattered F q -linear set of PG(r − 1, q n ), rn even, is at most rn/2 as it was proved by Blokhuis and Lavrauw. Existence results and explicit constructions were given for infinitely many values of r, n, q (rn even) for scattered F q -linear sets of rank rn/2. In this paper we prove that the bound rn/2 is sharp also in the remaining open cases.Recently Sheekey proved that scattered F q -linear sets of PG(1, q n ) of maximum rank n yield F q -linear MRD-codes with dimension 2n and minimum distance n − 1. We generalize this result and show that scattered F q -linear sets of PG(r − 1, q n ) of maximum rank rn/2 yield F q -linear MRD-codes with dimension rn and minimum distance n − 1.