Baffled city investigators began calling them “maple syrup events”: mysterious waves of sweet-smelling air that periodically wafted over Manhattan, delighting some, troubling others and vanishing as quickly as they had arrived.

After each episode  in 2005, 2006 and again this year  residents flooded the city’s 311 information hot line with calls. The city’s Department of Environmental Protection dispatched air testers. But nobody could pinpoint the smell  or its source.

So the aroma was filed away as another vexing urban mystery, never to be solved.

Until now.

The city revealed on Thursday that the culprit was the seeds of fenugreek, a cloverlike plant, which are used to produce fragrances at a factory across the Hudson River in North Bergen, N.J. It turned out that the city had never given up trying to determine the aroma’s origin. It had quietly created a crack maple-syrup team that remained on the case.

The North Bergen factory, owned by a company called Frutarom, used the herbal seeds to manufacture food flavors, releasing a pungent, generally pleasant smell in the process. Under the right weather conditions  high humidity, no rain  the aroma drifts across the Hudson onto the West Side of Manhattan.