A semiconductor device, comprising: a semiconductor substrate of a first conductivity type; and a Hall element formed in the semiconductor substrate, the Hall element comprising: a magnetic sensing portion formed of an impurity diffusion layer of a second conductivity type formed in the semiconductor substrate, and having four ends in plan view; and four electrodes provided at the respective four ends in a surface of the magnetic sensing portion, and each formed of an impurity diffusion layer of the second conductivity type having a concentration that is higher than a concentration of the magnetic sensing portion, the impurity diffusion layer which forms the magnetic sensing portion having a first depth from a surface of the semiconductor substrate, having a first concentration gradient in which a concentration of impurities of the second conductivity type increases in a depth direction from the surface of the semiconductor substrate to a second depth which is shallower than the first depth, and having a second concentration gradient in which the concentration of the impurities of the second conductivity type decreases in the depth direction from the second depth to the first depth, the second depth being half the first depth or less, the first concentration gradient being steeper than the second concentration gradient; and characterized in that the concentration of the impurities of the second conductivity type in the magnetic sensing portion has a peak between depths of 400 nm and 800 nm from the surface of the semiconductor substrate, the concentration at the peak being from 1×10 16 atoms/cm 3 to 1×10 17 atoms/cm 3, the magnetic sensing portion having a depth of from 2 μm to 5 μm. a semiconductor substrate of a first conductivity type; and a Hall element formed in the semiconductor substrate, the Hall element comprising: a magnetic sensing portion formed of an impurity diffusion layer of a second conductivity type formed in the semiconductor substrate, and having four ends in plan view; and four electrodes provided at the respective four ends in a surface of the magnetic sensing portion, and each formed of an impurity diffusion layer of the second conductivity type having a concentration that is higher than a concentration of the magnetic sensing portion, a magnetic sensing portion formed of an impurity diffusion layer of a second conductivity type formed in the semiconductor substrate, and having four ends in plan view; and four electrodes provided at the respective four ends in a surface of the magnetic sensing portion, and each formed of an impurity diffusion layer of the second conductivity type having a concentration that is higher than a concentration of the magnetic sensing portion, the impurity diffusion layer which forms the magnetic sensing portion having a first depth from a surface of the semiconductor substrate, having a first concentration gradient in which a concentration of impurities of the second conductivity type increases in a depth direction from the surface of the semiconductor substrate to a second depth which is shallower than the first depth, and having a second concentration gradient in which the concentration of the impurities of the second conductivity type decreases in the depth direction from the second depth to the first depth, the second depth being half the first depth or less, the first concentration gradient being steeper than the second concentration gradient; and characterized in that the concentration of the impurities of the second conductivity type in the magnetic sensing portion has a peak between depths of 400 nm and 800 nm from the surface of the semiconductor substrate, the concentration at the peak being from 1×10 16 atoms/cm 3 to 1×10 17 atoms/cm 3, the magnetic sensing portion having a depth of from 2 μm to 5 μm.