See the References Rod mentions. But, In simple terms....
Torque comes from burning more fuel during each power stroke or engine cycle. The limit on fuel is related to how much air can be induced into the cylinder for each engine cycle. How do I get more air... Turbo charge or super charge. Most diesels are turbo charged so they have more torque. Gasoline engines are limited with turbo charging because of knock.
Power comes from torque times engine speed. If you can rev an engine faster, you can typically get more power. But running higher engine speeds leaves less time for complete combustion. SI engines can rev higher than diesels because of the combustion is faster, due to two reasons. First, ignition with a spark is quicker than ignition by compression. Second, SI engines run premixed air/fuel charges that burn fast. This is compared to CI engines where mixing occurs during combustion, significantly slowing the combustion process.