The present invention relates to an LED lamp (1) adapted for operation with an alternating current. The LED retrofit lamp (1) comprises a LED unit (7, 7′, 7″, 7′″) and a compensation circuit with a controllable switching device (9, 9′), connected parallel to said LED unit (7, 7′, 7″, 7′″) to provide an alternate current path. A control unit (10, 10′, 10″) is adapted to control said switching device (9, 9′) in a compensation mode in which said switching device (9, 9′) is set to the conducting state for the duration of a shunt period in each half cycle of the alternating current to allow adapting the power/current of the inventive LED lamp (1), so that a versatile and optimized operation of the lamp (1) is possible.