A method of manufacturing a semiconductor device, comprising: preparing a silicon substrate; forming a buffer layer (230; 1200) on the silicon substrate; and forming a nitride semiconductor layer on the buffer layer (230; 1200), wherein the buffer layer (230; 1200) comprises: a first layer that comprises Al x In y Ga 1-x-y N (0≤ x≤ 1, 0≤ y≤ 1, 0≤ x+y≤ 1) and has a lattice constant LP1 that is smaller than a lattice constant LP0 of the silicon substrate; a second layer that is directly formed on the first layer, comprises Al x In y Ga 1-x-y N (0≤ x<1, 0≤ y<1, 0≤ x+y<1), and has a lattice constant LP2 that is smaller than LP0; a third layer on the second layer, and that comprises Al x In y Ga 1-x-y N (0≤ x<1, 0≤ y<1, 0≤ x+y<1), wherein the second layer has a lattice constant distribution that increases along a thickness direction, the third layer has a lattice constant LP3 that is smaller than a lattice constant average of the second layer; and the lattice constant of the second layer is greater than the lattice constant LP1, wherein the buffer layer further comprises a fourth layer that is directly formed on the third layer, comprises Al x In y Ga 1-x-y N (0≤ x<1, 0≤ y<1, 0≤ x+y<1), and has a lattice constant distribution that increases along a thickness direction, wherein the fourth layer has the same lattice constant average as the second layer, and wherein the third layer is formed to a thickness such that lattice relaxation occurs, characterized in that the third layer is directly formed on the second layer. preparing a silicon substrate; forming a buffer layer (230; 1200) on the silicon substrate; and forming a nitride semiconductor layer on the buffer layer (230; 1200), wherein the buffer layer (230; 1200) comprises: a first layer that comprises Al x In y Ga 1-x-y N (0≤ x≤ 1, 0≤ y≤ 1, 0≤ x+y≤ 1) and has a lattice constant LP1 that is smaller than a lattice constant LP0 of the silicon substrate; a second layer that is directly formed on the first layer, comprises Al x In y Ga 1-x-y N (0≤ x<1, 0≤ y<1, 0≤ x+y<1), and has a lattice constant LP2 that is smaller than LP0; a third layer on the second layer, and that comprises Al x In y Ga 1-x-y N (0≤ x<1, 0≤ y<1, 0≤ x+y<1), wherein the second layer has a lattice constant distribution that increases along a thickness direction, the third layer has a lattice constant LP3 that is smaller than a lattice constant average of the second layer; and the lattice constant of the second layer is greater than the lattice constant LP1, a first layer that comprises Al x In y Ga 1-x-y N (0≤ x≤ 1, 0≤ y≤ 1, 0≤ x+y≤ 1) and has a lattice constant LP1 that is smaller than a lattice constant LP0 of the silicon substrate; a second layer that is directly formed on the first layer, comprises Al x In y Ga 1-x-y N (0≤ x<1, 0≤ y<1, 0≤ x+y<1), and has a lattice constant LP2 that is smaller than LP0; a third layer on the second layer, and that comprises Al x In y Ga 1-x-y N (0≤ x<1, 0≤ y<1, 0≤ x+y<1), wherein the second layer has a lattice constant distribution that increases along a thickness direction, the third layer has a lattice constant LP3 that is smaller than a lattice constant average of the second layer; and the lattice constant of the second layer is greater than the lattice constant LP1, wherein the buffer layer further comprises a fourth layer that is directly formed on the third layer, comprises Al x In y Ga 1-x-y N (0≤ x<1, 0≤ y<1, 0≤ x+y<1), and has a lattice constant distribution that increases along a thickness direction, wherein the fourth layer has the same lattice constant average as the second layer, and wherein the third layer is formed to a thickness such that lattice relaxation occurs, characterized in that the third layer is directly formed on the second layer.