He did it by having Huell steal the pack of cigarettes with the ricin and makes Jesse think Gus stole it to poison Brock and frame Walt so Jesse would kill Walt.
Walt actually used the poisonous Lily of the Valley berries from his yard so that when the poison was identified (after Gus’s death) it could be ruled an accidental and natural event. Then Walt has to deal with Jesse not knowing where the ricin has gone and we get the roomba episode.
It is pretty convoluted, but fun.