Hydrogen and methane, as chemical raw materials with broad application prospects in the future market, can be produced by the two-phase anaerobic co-digestion of rice straw and sludge. The study was carried out using a medium-temperature batch experiment with rice straw, a rural crop residue from Sichuan, and residual sludge from a sewage treatment station. The effect of the mixing ratio of rice straw and rural sludge on hydrogen and methane production from anaerobic digestion was investigated with a view to alleviating the energy crisis and efficient resource utilization. The experimental results showed that hydrogen production was most favorable when rice straw/sludge = 5:1, with a cumulative hydrogen yield as high as 38.59 ± 1.12 mL/g VSadded, while methane production was most favorable when 3:1, with a cumulative methane yield as high as 578.21 ± 29.19 mL/g VSadded. By calculating the energy yield, it was determined that 3:1 is more favorable for the two-phase anaerobic digestion capacity of rice straw and sludge, which is as high as 20.88 ± 1.07 kJ/g VSadded, and its conversion of hydrogen and methane is 0.75% and 78.19%, respectively. The hydrogen production pathway was dominated by the butyric acid type, whose hydrogen production phase pH (5.84 ± 0.13) was slightly higher than the optimal pH for hydrogen-producing bacteria, while the methanogenic phase could meet the optimal pH for methanogenic bacteria (6.93 ± 0.17).