HMP Kingston is one of six jails in England to be closed by the Ministry of Justice (MoJ) as part of spending cuts.
Officers left the prison, by marching out the front gate together, at midday. Friends and family were then taken on a tour of the buildings and grounds.
Kingston housed around 800 Category C prisoners with indeterminate sentences. The government said the closures would save Â£63m per year in running costs.
The MoJ said the closures would result in the loss of 2,600 places from "old and uneconomic" prisons.
It plans to build a new 2,000-place super prison in London, north-west England or north Wales.
Unions have previously claimed up to 300 jobs could be lost in the closure of HMP Kingston and Camp Hill on the Isle of Wight.
Some staff from Kingston have already been redeployed to other sites.
Lou Ralls, chairman of the Portsmouth branch of the Prison Officers Association, said staff were "buoyant" despite the closure.
He said: "The announcement came as a shock as we regarded ourselves as a high-performing prison. We feel a pocket of excellence for the industry and the city has been lost.
"Around 8% of our members have taken voluntary redundancy.
"No compulsory redundancies have happened and 100% of staff who wished to relocate have been handed their first or second choice."

Robin Clark, 44, was shot in the leg in the car park at Shenfield station on 24 January, by a gunman in a balaclava.
He spent several weeks in hospital but has since returned to his job at RP Martin in London.
British Transport Police says a man from Essex has been arrested on suspicion of conspiracy to commit murder.
He has been released on bail pending further inquiries.
A Portsmouth prison built in 1877 has closed its doors for the last time.
[NEXT_CONCEPT]
Police investigating the shooting of a city trader at a station in Essex have arrested a 51-year-old man.