Portsmouth Police tweeted residents took refuge on the roof of the building while awaiting rescue.
People were told to avoid the area as firefighters from Hampshire Fire and Rescue worked to get the blaze on the fourth floor under control.
The fire was put out shortly before 15:00. Hampshire Fire and Rescue tweeted "everyone was safe".
The people on the roof were advised to wait until the smoke had dispersed to come down.
The fire service said it is believed the fire started in the kitchen.
An onlooker tweeted it was "chaos" in the area as the car park at Gunwharf Quays - a waterfront shopping outlet - was closed.
People living in nearby buildings were advised to keep windows and doors shut.

A number of houses were evacuated after the device was discovered on Ainsworth Avenue off the Shankill Road.
The security alert has now ended.
Police have appealed for information about the incident.
Democratic Unionist Party MLA William Humphrey said those behind the device had been "utterly reckless".
"This criminal act of madness will be condemned by all right-thinking people," he added.

The museum hopes to raise £5m to develop its Maryfield tram depot into a fully-restored national visitor attraction.
It has been based at its temporary headquarters in Market Street since April 2014.
The grant will fund a new museum director and consultancy post for two years.
The museum's chairman Jimmy McDonell said: "We are extremely privileged to have been offered this grant from the Mathew Trust.
"It will allow us to carry the project forward by bringing in the expertise we need to make the very best of this opportunity that we have."
The museum, which is run by volunteers, attracted more than 10,000 visitors in its first year.
VisitScotland regional director Jim Clarkson said: "In Scotland's Year of Innovation, Architecture and Design, the grant will help Dundee Museum of Transport remain an exciting part of the city's tourism offering, boosting the visitor economy in the process."

The Pilgrims have won nine of their last 10 league games and are five points clear at the top of League Two.
Last season's beaten play-off finalists beat Yeovil 4-1 on 1 October and have not lost in the league since 13 August.
"I've seen us in training and I've seen us perform and I still think we've got another gear in us," summer signing Bradley told BBC South West.
After last season's disappointment at Wembley, manager Derek Adams added 14 new signings and two more players on loan.
Former Crawley captain Bradley continued: "We're definitely capable of promotion.
"I've been part of different League Two squads up and down the country and I can tell you that if we play to our potential every week, we continue to listen to the manager and take on instructions, then this team is more than capable of automatic promotion.
"I wasn't here last season and don't have any reminders about Wembley and what happened.
"I don't care about that if I'm honest, all I care about is keeping clean sheets and making sure this club is getting where it needs to be. At the minute that's where we are - top of the table and on course for a successful season."
Firefighters tackled a large fire in a high-rise building in the Gunwharf Quays area of Portsmouth.
[NEXT_CONCEPT]
Police have said a suspicious object found in west Belfast was a "crude but viable" bomb.
[NEXT_CONCEPT]
Dundee Museum of Transport's fundraising campaign has received an £80,000 grant.
[NEXT_CONCEPT]
Plymouth Argyle defender Sonny Bradley says the League Two leaders still have better performances in them.