In cycles, how can I make an object opaque to the camera, but transparent to light?
I know this can be done in compositing, but is there a way to do it at render time.
You can do the same as you would if you wanted to make the object invisible to the camera yet still cast shadows etc, only in reverse:
This is equivalent to disabling Shadow ray visibility as NoviceInDisguise answered, but with nodes instead. Note that disabling the ray visibility in the object panel helps rendertimes a little more than using nodes, but if you want to use it inside a larger setup it may be necessary to use nodes.
Uncheck Shadow in the Ray Visibility options.
This makes it so that the object does not cast shadows, and as you can see, the plane is illuminated as if the sphere was not even there, while the sphere itself is still illuminated properly.
It can be tedious to set this setting for each object, so there is a shortcut. Select all the objects you want to have this setting, then change the setting (all still selected) and right-click on the checkbox and choose Copy to Selected.
I'm just guessing here, so I could be wrong. But the "Light Path" node has an output value that tells you if the light ray is heading for the camera.
You might be able to use this as the fac input of a "Mix Shader" node. It might still generate a bit of a shadow because some of the light is being blocked by the object.