That is indeed the case on Mars. Ancient lava fields indicate a planet-wide magnetic field, while more recent ones do not. It is believed that, once its core cooled down and could no longer generate a global magnetic field, Mars lost its "shield" from incoming cosmic rays (charged particles from, mostly, outside the solar system) and its atmosphere was blown away.
The following NOVA doc covers this very well...
Nova - Magnetic Storm - Earth's Invisible Shield:
Do you see why I say to folks asking, “Where did it go?”- Look out your window.