A semiconductor device, comprising: a first conductivity type first semiconductor layer; a second conductivity type second semiconductor layer provided on the first semiconductor layer; a first conductivity type third semiconductor layer selectively provided in a surface layer of the second semiconductor layer on the side opposite to that of the first semiconductor layer; a second conductivity type fourth semiconductor layer selectively provided inside the third semiconductor layer; a first trench penetrating the third semiconductor layer and fourth semiconductor layer to reach the second semiconductor layer; a first conductivity type fifth semiconductor layer, selectively provided in a surface layer of the second semiconductor layer on the side opposite to that of the first semiconductor layer, separated from the third semiconductor layer by the first trench; a second trench reaching the second semiconductor layer from the surface of the fifth semiconductor layer on the side opposite to that of the first semiconductor layer; a first conductivity type sixth semiconductor layer, selectively provided in a surface layer of the second semiconductor layer on the side opposite to that of the first semiconductor layer separated from the fifth semiconductor layer by the second trench; an emitter electrode conductively connected to the third semiconductor layer, fourth semiconductor layer, and sixth semiconductor layer and electrically isolated from the fifth semiconductor layer; a collector electrode conductively connected to the first semiconductor layer; a first gate electrode provided across a first gate insulating film inside the first trench; and a second gate electrode provided across a second gate insulating film inside the second trench and electrically connected to the emitter electrode, characterized in that the width of the sixth semiconductor layer is less than the width of the third semiconductor layer. a first conductivity type first semiconductor layer; a second conductivity type second semiconductor layer provided on the first semiconductor layer; a first conductivity type third semiconductor layer selectively provided in a surface layer of the second semiconductor layer on the side opposite to that of the first semiconductor layer; a second conductivity type fourth semiconductor layer selectively provided inside the third semiconductor layer; a first trench penetrating the third semiconductor layer and fourth semiconductor layer to reach the second semiconductor layer; a first conductivity type fifth semiconductor layer, selectively provided in a surface layer of the second semiconductor layer on the side opposite to that of the first semiconductor layer, separated from the third semiconductor layer by the first trench; a second trench reaching the second semiconductor layer from the surface of the fifth semiconductor layer on the side opposite to that of the first semiconductor layer; a first conductivity type sixth semiconductor layer, selectively provided in a surface layer of the second semiconductor layer on the side opposite to that of the first semiconductor layer separated from the fifth semiconductor layer by the second trench; an emitter electrode conductively connected to the third semiconductor layer, fourth semiconductor layer, and sixth semiconductor layer and electrically isolated from the fifth semiconductor layer; a collector electrode conductively connected to the first semiconductor layer; a first gate electrode provided across a first gate insulating film inside the first trench; and a second gate electrode provided across a second gate insulating film inside the second trench and electrically connected to the emitter electrode, characterized in that the width of the sixth semiconductor layer is less than the width of the third semiconductor layer.