A semiconductor laser comprises: a substrate; an n-cladding layer disposed on the substrate; an active layer disposed on the n-cladding layer; a p-cladding layer disposed on the active layer and forming a waveguide ridge; and a diffraction grating layer disposed between the active layer and the n-cladding layer or the p-cladding layer and including a phase shift structure in a part of the diffraction grating layer in an optical waveguide direction. The width of the p-cladding layer is increased in a portion corresponding to the phase shift structure of the diffraction grating layer.