Portable long-barrelled firearm or pneumatic weapon (A, A') comprising a safety device (10, 20) and intended to be gripped by a user with both hands and comprising: - a firing mechanism, including at least one trigger, intended to be operated by the user's hand, - a grip (12, 22), intended to be held by the user's other hand, and - a selective locking mechanism (100, 200) of said firing mechanism, operatively switchable from a deactivated position, in which it allows firing of the weapon, to an activated position, in which it prevents firing of the weapon, wherein said safety device comprises: - means to control the operating condition of said locking mechanism of said firing mechanism (13, 23), which are provided in said grip (12, 22) and, when the weapon is gripped correctly and naturally by the user, automatically cause deactivation of said selective locking mechanism (100, 200), allowing firing of the weapon (A, A'), while, when said grip (12, 22) is released by the user, automatically cause activation of said locking mechanism of said firing mechanism, preventing firing of said weapon (A, A'), wherein said control means comprise a part (13, 23) of said grip (12, 22) movable between a rest position and an operating position, wherein said selective locking mechanism (100, 200) of said firing mechanism comprises stop means movable between a locking position and a release position of said firing mechanism, which are connected kinematically with respect to said moving part (13, 23) of said grip, so that when said grip is gripped correctly and naturally by a user said moving part (13, 23) is automatically set to said operating position and said stop means are automatically set to said release position, while when said grip is released by the user said moving part is automatically set to said rest position and said stop means are automatically set to said locking position, wherein said safety device comprises: - said moving part (13, 23) of said grip (12, 22); - a connection mechanism between a first pivoting lever means (14, 24), operated by said moving part (13, 23) of said grip (12, 22), and a second pivoting lever means, which in a first pivoted operating position interfere directly or indirectly with said firing mechanism, preventing firing of said weapon (A, A'), wherein when said grip (12, 22) is gripped by the user to fire the weapon (A, A'), said moving part (13, 23) of the grip is automatically set to said operating position and causes pivoting of said first lever means (14, 24), countering the action of a first automatic return means (16, 38, 17, 26), to an operating position in which said first lever means (14, 24), via said connection mechanism, cause said second lever means to pivot to a second pivoted operating position, in which said second lever means do not interfere directly or indirectly with said firing mechanism, allowing firing of the weapon (A, A'), while when said grip (12, 22) is released by the user, said moving part (13, 23) of the grip and said first lever means (14, 24) are automatically set, via said first automatic return means (16, 38, 17, 26), to a respective rest position and allow said second lever means to automatically return to said first pivoted operating position, preventing firing of said weapon (A, A'), and characterized in that said connection mechanism comprises at least one connecting rod (18, 28) jointed at its ends with respect to said first (14, 24) and second pivoting lever means, to provide the jointed connection between said lever means (14, 24,15), and in that said connecting rod comprises a joint in the intermediate position to allow the opening and closing of said portable firearm or pneumatic weapon. - a firing mechanism, including at least one trigger, intended to be operated by the user's hand, - a grip (12, 22), intended to be held by the user's other hand, and - a selective locking mechanism (100, 200) of said firing mechanism, operatively switchable from a deactivated position, in which it allows firing of the weapon, to an activated position, in which it prevents firing of the weapon, - means to control the operating condition of said locking mechanism of said firing mechanism (13, 23), which are provided in said grip (12, 22) and, when the weapon is gripped correctly and naturally by the user, automatically cause deactivation of said selective locking mechanism (100, 200), allowing firing of the weapon (A, A'), while, when said grip (12, 22) is released by the user, automatically cause activation of said locking mechanism of said firing mechanism, preventing firing of said weapon (A, A'), - said moving part (13, 23) of said grip (12, 22); - a connection mechanism between a first pivoting lever means (14, 24), operated by said moving part (13, 23) of said grip (12, 22), and a second pivoting lever means, which in a first pivoted operating position interfere directly or indirectly with said firing mechanism, preventing firing of said weapon (A, A'),