A barrel unit for a firearm, including a barrel with a barrel axis, muzzle and a barrel end opposite the muzzle, on which at least two barrel lugs are formed, and a barrel extension with a barrel receptacle and a first end and a second end, wherein inwardly extending locking lugs are formed on the first end, to work together with a bolt, and inwardly extending barrel locking lugs are formed closer to the second end than the locking lugs. A barrel cam on the outer surface cooperates with a cam lug arranged on the barrel extension to fix the barrel in a predefined end position.