A semiconductor device comprising: a semiconductor substrate ; an insulating film that is provided on the semiconductor substrate ; and a protective element that is made of a polysilicon layer provided on the insulating film and clamps a surge voltage, wherein the protective element has a unit structure including a first semiconductor layer of a first conductivity type , a second semiconductor layer of the first conductivity type which comes into contact with one end of the first semiconductor layer and has a lower impurity concentration than the first semiconductor layer , a third semiconductor layer of a second conductivity type which comes into contact with the other end of the second semiconductor layer and has a higher impurity concentration than the second semiconductor layer , and a fourth semiconductor layer of the first conductivity type which comes into contact with one end of the third semiconductor layer and has an impurity concentration that is lower than the impurity concentration of the third semiconductor layer and is substantially equal to the impurity concentration of the second semiconductor layer , or two or more unit structures that are connected in series to each other, one end of the protective element is the first semiconductor layer , the other end of the protective element is a fifth semiconductor layer of the first conductivity type which has an impurity concentration that is substantially equal to the impurity concentration of the first semiconductor layer , characterized in that high-resistance layers which have a greater resistance value than the second semiconductor layer or the fourth semiconductor layer are provided at both ends of the protective element in a direction perpendicular to a direction in which the first semiconductor layer , the second semiconductor layer , the third semiconductor layer , and the fourth semiconductor layer forming the unit structure are arranged in a line. a semiconductor substrate ; an insulating film that is provided on the semiconductor substrate ; and a protective element that is made of a polysilicon layer provided on the insulating film and clamps a surge voltage, wherein the protective element has a unit structure including a first semiconductor layer of a first conductivity type , a second semiconductor layer of the first conductivity type which comes into contact with one end of the first semiconductor layer and has a lower impurity concentration than the first semiconductor layer , a third semiconductor layer of a second conductivity type which comes into contact with the other end of the second semiconductor layer and has a higher impurity concentration than the second semiconductor layer , and a fourth semiconductor layer of the first conductivity type which comes into contact with one end of the third semiconductor layer and has an impurity concentration that is lower than the impurity concentration of the third semiconductor layer and is substantially equal to the impurity concentration of the second semiconductor layer , or two or more unit structures that are connected in series to each other, one end of the protective element is the first semiconductor layer , the other end of the protective element is a fifth semiconductor layer of the first conductivity type which has an impurity concentration that is substantially equal to the impurity concentration of the first semiconductor layer , characterized in that high-resistance layers which have a greater resistance value than the second semiconductor layer or the fourth semiconductor layer are provided at both ends of the protective element in a direction perpendicular to a direction in which the first semiconductor layer , the second semiconductor layer , the third semiconductor layer , and the fourth semiconductor layer forming the unit structure are arranged in a line. <EOS>