I would like my mountain to be invisible after rendering. And I want just Objects in front of it (like trees) to be seen, but not behind the mountain.
To make the object transparent as alpha channel:
use a holdout shader so it renders as transparent
Place the object on a different layer and use that layer as mask:
Use a Pass index for the object and use that on the compositor to substract the object from the final render:
Similarly, you can assign a pass index to the material and use that as alpha on the compositor: