A cease-fire took hold Friday night in eastern Ukraine after the president's representative signed a deal with Russian-backed separatists in an effort to bring an end to nearly five months of fighting.

President Petro Poroshenko said he ordered government forces to stop hostilities at 6 p.m. local time following a protocol signed by representatives of Ukraine, Russia, the rebels and the Organization for Security and Cooperation in Europe at talks in Minsk, the Belarusian capital.

"Human life is of the highest value. And we need to do everything that is possible and impossible to stop the bloodshed and end people's suffering," Poroshenko said in a statement.

The Donetsk separatists said on Twitter that they also have ceased fire.

After announcing the cease-fire, negotiators met for two more hours and agreed upon the withdrawal of all heavy weaponry, the release of all prisoners and the delivery of humanitarian aid to devastated cities in eastern Ukraine, Heidi Tagliavini of the OSCE told reporters in Minsk.

Mikhail Zurabov, the Russian ambassador to Ukraine who also signed the deal, described the exchange of lists of more than 1,000 prisoners from each side as a "breakthrough."

Poroshenko said a prisoner exchange could begin as early as Saturday and international monitors from the OSCE would keep watch over the cease-fire.

With this deal, Russian President Vladimir Putin may hope to avert a new round of Western sanctions.

U.S. President Barack Obama said he was hopeful the cease-fire would hold, but skeptical that the rebels would follow through and that Russia would stop violating Ukraine's sovereignty and territorial integrity.

"It has to be tested," Obama said at the close of a two-day NATO summit in Wales.

Noting that the U.S. and Europe were finalizing even tougher sanctions on Moscow, Obama said the most effective way to ensure the cease-fire's success was to move ahead with those sanctions to keep up the pressure on Russia.

Since mid-April, Moscow-backed separatists have been fighting government troops in eastern Ukraine in a conflict the U.N. estimates has killed nearly 2,600 people and forced hundreds of thousands to flee their homes.

"The cease-fire will allow us to save not only civilians lives, but also the lives of the people who took up arms in order to defend their land and ideals," said Alexander Zakharchenko, the rebel leader from the Donetsk region.

Igor Plotnitsky, leader of the separatist Luhansk region, also told reporters that his forces would respect the cease-fire.

Moscow has denied reports by Ukraine, NATO and Western nations that it was backing the mutiny with weapons, supplies, and even with thousands of regular troops. But a NATO military officer told The Associated Press that the number of Russian soldiers directly involved in the conflict has grown past NATO's earlier estimate of at least 1,000.

Leonid Kuchma, a former president of Ukraine, represented Poroshenko at the talks.

"There was a genuine desire that there will be peace in that region. I think we will achieve it," Kuchma said. He added, however, that even though both Poroshenko and the separatist leaders have ordered their forces to stop fighting "it doesn't mean that someone will not fire from behind the corner."

Kuchma said a task force will be set up by Monday to organize not only the exchange of prisoners and delivery of humanitarian aid, but also to establish how the eastern regions of Ukraine will be governed.

At the summit in Wales, NATO leaders approved plans Friday to create a rapid response force to counter Russian aggression, with a headquarters in Eastern Europe that could quickly mobilize if an alliance country came under attack. Ukraine is not a NATO member, but the entire alliance has been alarmed by Russia's actions in Ukraine, and Russia is under both U.S. and EU sanctions for its backing of the rebels.

German Chancellor Angela Merkel said "if certain processes get underway, we are prepared to suspend sanctions" against Russia.

"We have to see whether this cease-fire is being applied," she added. "Do Russian troops withdraw, so far as they're there? Are there buffer zones and things like that -- a lot of things will have to be sorted out."

A rebel offensive in southeast Ukraine in the last two weeks has turned the tide of the war against Ukrainian forces, who until recently had appeared close to crushing the rebellion.

On Friday morning, Associated Press reporters heard heavy shelling north and east of the key southeastern port of Mariupol. The city of 500,000 lies on the Sea of Azov, between Russia to the east and the Crimean Peninsula to the west, which Russia annexed in March. The shelling appeared to indicate that rebels had partially surrounded the area.

The seizure of Mariupol would give the rebels a strong foothold on the sea coast and raise the threat that they could carve out a land corridor between Russia and Crimea. If that happened, Ukraine would lose another huge chunk of its coast and access to the rich hydrocarbon resources the Sea of Azov is believed to hold. Ukraine already lost about half its coastline, several major ports and untold billions in Black Sea mineral rights with Russia's annexation of Crimea.

"Mariupol is a strategic point. If we lose it then we could lose the entire coastline, the whole south of Ukraine," said Tatyana Chronovil, a Ukrainian activist at a mustering point for the volunteer Azov Battalion on the eastern edge of the city.

But as the cease-fire went into effect Friday evening, AP reporters heard no shelling in Mariupol for several hours and several Ukrainian tanks returned to the city.

In Donetsk, the largest rebel-held city, some shelling was heard after the cease-fire was declared, but within an hour the guns appeared to have gone silent.