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 (31-34) 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 (D1) from a surface of the semiconductor substrate , having a first concentration gradient (S1) 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 (D2) which is shallower than the first depth (D1), and having a second concentration gradient (S2) in which the concentration of the impurities of the second conductivity type decreases in the depth direction from the second depth (D2) to the first depth (D1), the second depth (D2) being half the first depth (D1) or less, the first concentration gradient (S1) being steeper than the second concentration gradient (S2); 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 (31-34) 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 (31-34) 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 (D1) from a surface of the semiconductor substrate , having a first concentration gradient (S1) 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 (D2) which is shallower than the first depth (D1), and having a second concentration gradient (S2) in which the concentration of the impurities of the second conductivity type decreases in the depth direction from the second depth (D2) to the first depth (D1), the second depth (D2) being half the first depth (D1) or less, the first concentration gradient (S1) being steeper than the second concentration gradient (S2); 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. <EOS>