When he was released  he had served nine years in prison.
When he was released  he had served nine years in prison.
He had served nine years in prison for the crime -- two on death row -- when he was released.