According to one embodiment, a magnetoresistive element is disclosed. The magnetoresistive element includes an underlayer containing aluminum (Al), nitrogen (N) and X. The X is an element other than Al and N. A first magnetic layer is provided on the underlayer. A nonmagnetic layer is provided on the first magnetic layer. A second magnetic layer is provided on the nonmagnetic layer.