RWE is to supply the railway operator with about 900 million kilowatt hours of electricity per year, enough to run about one third of the DB's long distance trains for a year.
The same quantity would supply 250,000 German households for a similar period.
RWE, the second biggest German power group, is building up its capacity to produce renewable energy as the government phases out nuclear power by 2022 in Europe's biggest economy.
Deutsche Bahn bills itself meanwhile as the "biggest consumer of green energy" in Germany, and the percentage of electricity generated by renewable sources for the railway is to increase from 19.8 percent to 28 percent.
The contract covers the period from 2014 to 2028 and is to involve output from 14 hydro-electric generating plants.
By 2013, RWE said it will have invested almost €4 billion in expanding its alternative energy production capacity.
"With this move, we are getting closer to our vision of meeting all the railways' electricity needs with renewable energy by 2050," DB chairman Rüdiger Grube as said in a statement.