It has been recently proposed that giant protoplanets migrating inwards through the disc more rapidly than they contract could be tidally disrupted when they fill their Roche lobes ∼0.1 au away from their parent protostars. Here we consider the process of mass and angular momentum exchange between the tidally disrupted planet and the surrounding disc in detail. We find that the planet's adiabatic mass–radius relation and its ability to open a deep gap in the disc determine whether the disruption proceeds as a sudden runaway or a balanced quasi-static process. In the latter case, the planet feeds the inner disc through its Lagrangian L1 point like a secondary star in a stellar binary system. As the planet loses mass, it gains specific angular momentum and normally migrates in the outward direction until the gap closes. Numerical experiments show that planet disruption outbursts are preceded by long ‘quiescent’ periods during which the disc inward of the planet is empty. The hole in the disc is created when the planet opens a deep gap, letting the inner disc to drain on to the star while keeping the outer one stalled behind the planet. We find that the mass-losing planet embedded in a realistic protoplanetary disc spawns an extremely rich set of variability patterns. In a subset of parameter space, there is a limit cycle behaviour caused by non-linear interaction between the planet mass-loss and the disc hydrogen ionization instability. We suggest that tidal disruptions of young massive planets near their stars may be responsible for the observed variability of young accreting protostars such as FU Ori, EXor and T Tauri stars in general.