A Hartlepool medical centre threatened with closure has been saved in what has been described as “a victory for patients”.