A process is described for the recovery of CO and optionally hydrogen from a stream containing CO, H2, methane, and hydrocarbons heavier than methane. The process is characterized by a two-stage removal (3, 6) of C2+ hydrocarbons from the feed. In a first step the feed gas (1) is separated (3) into a first C2+ depleted stream (5) and a first C2+ enriched stream (4). The first C2-enriched stream (4) is rectified (6) to produce a second C2+ depleted stream. The first and second C2+ depleted streams (5, 9) are fed to a cryogenic system (10) fro recovery of CO (12) and optionally hydrogen (11).