Anderson said it was disappointing not to be able to see his contract out.
"I am grateful to Somerset for giving me an opportunity to play cricket in England and only sorry that I've been unable to conclude my stay with them," he said on the club's website.
"However, I hope at some point in the future, when my back problem has been resolved, that I'll be able to return."
-AAP
Somerset director of cricket Matt Maynard said Anderson had impressed in his time at Taunton.
"It's disappointing Corey has had to return to New Zealand, particularly in light of what he has achieved during his short time with us.
"During his time here, Corey has soldiered on bravely and managed his ongoing stress fracture well, but now it needs immediate treatment.
"We have really enjoyed having him around and he has made a positive contribution, both on and off the field, at the club. Hopefully, we will see him again in the future."