A leisure centre blighted by closure fears is to remain open for the next decade - and is set to enjoy a £2.6m investment.