A gas sensor (1; 101; 201; 301), comprising: a sensor element extending axially of the gas sensor (1; 101; 201; 301) and having a gas sensing portion at a front end thereof and an electrode portion at a rear end thereof; a cylindrical metal shell retaining therein the sensor element with the gas sensing portion and the electrode portion protruding from front and rear ends of the metal shell, respectively, and having a flange portion and a rear end portion on a rear side of the flange portion; a cylindrical protection cover having a front end fitted onto the rear end portion of the metal shell so as to cover the electrode portion; and a weld joint through which the entire circumference of the front end of the protection cover is joined to the metal shell, wherein the rear end portion of the metal shell includes a first cylindrical section and a second cylindrical section located on a rear side of the first cylindrical section and being smaller in diameter than the first cylindrical section; the front end of the protection cover is placed around the second cylindrical section of the rear end portion of the metal shell; characterized in that the front end of the protection cover and the rear end portion of the metal shell are swaged radially inwardly to form a swaged part circumferentially astride from an end face of the front end of the protection cover to the first cylindrical section of the rear end portion of the metal shell; and the weld joint is formed circumferentially so as to extend from the end face of the swaged front end of the protection cover to the first cylindrical section of the swaged rear end portion of the metal shell, a sensor element extending axially of the gas sensor (1; 101; 201; 301) and having a gas sensing portion at a front end thereof and an electrode portion at a rear end thereof; a cylindrical metal shell retaining therein the sensor element with the gas sensing portion and the electrode portion protruding from front and rear ends of the metal shell, respectively, and having a flange portion and a rear end portion on a rear side of the flange portion; a cylindrical protection cover having a front end fitted onto the rear end portion of the metal shell so as to cover the electrode portion; and a weld joint through which the entire circumference of the front end of the protection cover is joined to the metal shell, wherein the rear end portion of the metal shell includes a first cylindrical section and a second cylindrical section located on a rear side of the first cylindrical section and being smaller in diameter than the first cylindrical section; the front end of the protection cover is placed around the second cylindrical section of the rear end portion of the metal shell; characterized in that the front end of the protection cover and the rear end portion of the metal shell are swaged radially inwardly to form a swaged part circumferentially astride from an end face of the front end of the protection cover to the first cylindrical section of the rear end portion of the metal shell; and the weld joint is formed circumferentially so as to extend from the end face of the swaged front end of the protection cover to the first cylindrical section of the swaged rear end portion of the metal shell,