Yemen’s warring parties have agreed to an immediate ceasefire in the Red Sea port of Hodeidah, the UN secretary general has said, in a potential breakthrough at the end of a week of peace talks in Sweden.

Antonio Guterres said the agreement included the future deployment of UN-supervised neutral forces and the establishment of humanitarian corridors. Troops from both sides will withdraw from the entire Hodeidah area within a maximum of 21 days in a process overseen by a UN-chaired committee.

A political framework for Yemen will be discussed in a next round of meetings, scheduled for late January.

If implemented on the ground, the deal would represent a breakthrough because the port is the gateway for the bulk of humanitarian aid coming into the country, and has been the subject of intense fighting. Ceasefires have also been agreed at two other ports, Salif and Ras Issa.

Guterres said the UN would play a key role when the troops withdrew. “It is obvious the UN will play an important role in the port, probably a monitoring role and the management of that port,” he said. This would help “facilitate the humanitarian flow of goods to the civilian population and it will improve the living conditions for millions of Yemenis”.

The UN special envoy for Yemen, Martin Griffiths, said troops would withdraw from the port within days, and from the wider city in a second phase. He said the ceasefire was designed to open up the east-west road that connects Hodeidah to the capital, Sana’a “so that the humanitarian pipeline, which is crucial to the people of Yemen, can start delivering aid”.

Agreements have also been reached on a mass prisoner swap and the easing of the siege of the south-western city of Taiz.

Guterres said the UN security council would discuss the terms of a draft resolution designed to monitor and verify the troop withdrawal agreements on Friday. Western powers will offer to provide technology to monitor the redeployments, with an agreement that policing in Hodeidah becomes the responsibility of “local security forces in accordance with Yemini law”.

He said the outcome of the talks in the Swedish town of Rimbo would mean “concrete results in the daily lives of Yemenis”.

The UN-backed Yemeni government lost control of Hodeidah and Sana’a to Iranian-backed Houthi rebels in 2015. Despite heavy military support from Saudi Arabia and the United Arab Emirate, the government, which is based in Aden, has been unable to take back either city.

Western backing for the Saudi-led war has frayed in the face of mass casualties, starvation and, more recently, allegations that the Saudi crown prince, Mohammed bin Salman, was instrumental in organising the killing of the Washington Post contributor Jamal Khashoggi.

The agreements, sealed with a handshake between the two sets of negotiators but not any signatures, include the shoring up of the country’s central bank, which should eventually enable the payment of salaries to 1.2 million public sector workers.

The plan raises questions about the capacity of the UN to administer Hodeidah port, including ensuring revenue from it is transferred to Yemen’s central bank. If it fails, the risk remains that fighting for control of the port will continue. Nearly 27% of the Houthi movement’s income comes from the port.

The UK foreign secretary, Jeremy Hunt, who flew to Sweden to attend the final day of the talks, said: “It is now vital that the parties act in good faith and take urgent steps to implement these agreements.”

Griffiths had never expected to reach an overall political settlement in this round of talks, the first since 2016, but he said the agreements covered the most sensitive, dangerous and difficult part of Yemen.

He overcame obstacles to the talks ever starting, including the size of the Houthi delegations, its means of transport to Sweden and a demand that 50 of its most seriously injured fighters be flown to Oman for medical treatment.

Despite the antagonism and brutality of the war, many of the talks in Sweden were conducted face to face. Pictures from inside the conference showed the two teams of negotiators smiling and shaking hands.

Backing in the US Senate for the for the Saudi war in Yemen is declining rapidly, placing pressure on the secretary of state, Mike Pompeo, to urge Washington’s allies to negotiate an end to the conflict.

With both sides suspicious that the other will not honour the agreements struck, Griffiths has tried to draw up detailed implementation plans in an attempt to prevent backsliding.

In Hodeidah, Salem Jaffer Baobaid, an aid worker with Islamic Relief, said: “It is much quieter today. We are not sure what is going to happen, but any relief is welcome.”

Baseem al-Janani, a local resident, said: “We have heard about the ceasefire, but we are very cautious. Today the Houthis dug new trenches, closed off and emptied some neighbourhoods. They do not seem like they are going to stop fighting.”