What Is the Difference Between a CT Scan and MRI?

A CT scan and MRI are both non invasive and low risk tools used by doctors to diagnose specific conditions. They both produce images of the inside of our body, but what are the differences between a CT scan and MRI, and when are they used?