Under threat of execution after his conviction by the Time Lords at the end of The War Games, the Doctor is granted a reprieve if he agrees to undertake missions for the Celestial Intervention Agency.
The Doctor is given a chance to avoid execution by agreeing to work for the Celestial Intervention Agency, which was established as a result of his involvement in "The War Games."