In the late 1990s, prodded by the United States, the Lebanese government vowed to eliminate the persistent problem of hashish cultivation in the lawless Bekaa Valley. The government bought 3,000 American dairy cows to help farmers survive without relying on hashish.

But the farmers had no experience feeding and milking cows. And the cattle needed imported, expensive feed that the farmers could not afford. When the cows did not produce enough milk to keep the farmers afloat, they blamed the United States. These complaints reached Iran, which stepped in with $50 million in farm aid for Lebanon, including cheaper cows that were easier for the Shiite Muslim farmers to feed and maintain. The United States had bungled a seemingly simple case of foreign aid, and Iran reaped the benefits.

This “cow vs. cow competition,” as Neil MacFarquhar writes, demonstrates the kind of unintended consequences that have accompanied decades of United States policies in the Middle East. Mr. MacFarquhar’s sly, vivid memoir, “The Media Relations Department of Hizbollah Wishes You a Happy Birthday,” is full of such anecdotes backed up by perceptive analysis. Whenever America tries to impose change from outside, it leads either to disaster (Iraq) or preservation of the status quo (Egypt, Saudi Arabia and much of the region).

Mr. MacFarquhar, the United Nations bureau chief for The New York Times, spent more than 13 years as a correspondent in the Middle East, first for The Associated Press and later for The Times. But his affection for the region is rooted in his childhood: he grew up in a Libyan oil town, where his father managed a refinery and a water desalinization plant. Mr. MacFarquhar writes wistfully of family barbecues on a sandy Mediterranean coast in an enclave inhabited by Westerners where he learned little about the world outside. The stories of his childhood in Libya are quite compelling, but they do not permeate the book as much as they should.