A system for variable actuation of an engine valve of an internal-combustion engine, comprising: - a hydraulic apparatus including: - a master piston, - a slave piston (44, 46) that can be driven by said master piston by means of a volume of fluid set between said master piston and said slave piston, and - a solenoid valve configured for assuming a state in which said volume of fluid is set in communication with an outlet so as to render said slave piston independent from the movement of said master piston; wherein said system further comprises: - a camshaft designed to drive said master piston in motion; - a control unit configured for controlling said solenoid valve so as to govern said engine valve, within said four-stroke engine operating mode, according to a lift and/or opening and closing times that are variable as a function of one or more parameters indicative of the operating conditions of the engine; said system being characterized in that: - said camshaft has a cam provided with a composite profile that is defined by a first portion for governing, through the master piston, the engine valve at least in a four-stroke engine operating mode, and that is moreover defined by a second portion for governing the engine valve at least in a two-stroke engine operating mode; and - said control unit is configured for selecting either the two-stroke operating mode or the four-stroke operating mode as a function of the conditions of engine load, and, on the basis of the mode selected, for controlling said solenoid valve so as to render said slave piston independent from said master piston along said second portion of said composite cam profile and/or along said first portion of said composite cam profile. - a hydraulic apparatus including: - a master piston, - a slave piston (44, 46) that can be driven by said master piston by means of a volume of fluid set between said master piston and said slave piston, and - a solenoid valve configured for assuming a state in which said volume of fluid is set in communication with an outlet so as to render said slave piston independent from the movement of said master piston; - a master piston, - a slave piston (44, 46) that can be driven by said master piston by means of a volume of fluid set between said master piston and said slave piston, and - a solenoid valve configured for assuming a state in which said volume of fluid is set in communication with an outlet so as to render said slave piston independent from the movement of said master piston; - a camshaft designed to drive said master piston in motion; - a control unit configured for controlling said solenoid valve so as to govern said engine valve, within said four-stroke engine operating mode, according to a lift and/or opening and closing times that are variable as a function of one or more parameters indicative of the operating conditions of the engine; - said camshaft has a cam provided with a composite profile that is defined by a first portion for governing, through the master piston, the engine valve at least in a four-stroke engine operating mode, and that is moreover defined by a second portion for governing the engine valve at least in a two-stroke engine operating mode; and - said control unit is configured for selecting either the two-stroke operating mode or the four-stroke operating mode as a function of the conditions of engine load, and, on the basis of the mode selected, for controlling said solenoid valve so as to render said slave piston independent from said master piston along said second portion of said composite cam profile and/or along said first portion of said composite cam profile.