NAIROBI, Kenya — The crew of the Naham 3, a longline fishing trawler, will never forget the day in 2012 when they disappeared.

In the early morning hours of March 26, somewhere in the deep blue waters of the western Indian Ocean near the Seychelles, a small boat emerged out of the murk. It zoomed toward the Naham 3 with a burst of gunfire.

“It’s the pirates! It’s the pirates!” the captain yelled.

What followed were four and half years of captivity, during which the crew members were beaten with bamboo poles, ate rats to survive and were held at gunpoint in a sweltering stretch of Somalian desert by a band of pirates who were convinced they were going to make many millions of dollars.

It all ended this weekend. The pirates finally relented, accepting a smaller amount to release the 26 surviving members of the Naham 3 crew after one of the longest pirate hostage ordeals ever endured.