Lighting objects passing through a portal in Cycles
Figured it out myself. It can be done by stacking three renders: At the bottom the interior of the portal, on the next level the exterior without the cylinder but with the shadow of the outer part of the cylinder, and finally on top the partially covered cylinder. The node setup looks like this:



And here's the result: