DHAKA, Bangladesh — The most powerful storm to hit Bangladesh in years tore into the country over the weekend, uprooting trees, destroying thousands of homes and killing five people, but spared this crowded nation from worse damage.

G.M. Abdul Quader, the joint secretary of Bangladesh’s Ministry of Disaster Management and Relief, said the authorities had prepared aggressively for the storm, Cyclone Fani, which barreled up the Bay of Bengal with wind speeds of 120 miles per hour.

As in neighboring India, where the storm made landfall on Friday before heading northeast, in Bangladesh thousands of volunteers had woven through villages with megaphones, warning people about the impending storm’s dangers and urging them to move to shelters. Both countries also sent extensive text messages to the tens of millions of people in the cyclone’s path.