They nearly died several times and Doucette slowly convinced Bellamy to start praying to the Shepherd, leading to visions of both the Shepherd and Bellamy's mother. By the time the two men finally got back to Bardo, Bellamy was ready to pledge himself fully to the Shepherd Bill Cadogan (John Pyper-Ferguson) and betray his friends, starting with Clarke.
He immediately told Cadogan that Clarke did not, in fact, have the Flame, the AI device that apparently contains the code to starting the Last War. He negotiated to keep Clarke and the others alive, but made it very clear that he was firmly on Cadogan's side and would do anything to help his new boss get ahold of that code.
Clarke led everyone back to Sanctum and gave Cadogan the broken Flame and it all would have worked out if Gabriel (Chuku Modu) hadn't decided to destroy it completely, leaving former Commander Madi and her drawings as the only remaining source of the code.
Bellamy told Clarke he knew she wouldn't shoot him and he just had to hand over the drawings to Cadogan, so Clarke apparently had no choice other than to actually shoot him in order to protect her daughter.