Updated

The mystery of how nearly $5 million in diamonds went missing from a Midtown jewelry store has been solved.

As it turns out, some dimwitted workers at J. Birnbach Inc. were helping their boss move to another floor and tossed three weathered wooden boxes filled with diamonds in a heap of trash without bothering to look inside, law-enforcement sources said.

But a building security guard patrolling the third floor allegedly did take a peek — and discovered the mother lode: a cluster of expensive stones, including one worth $3.2 million.

Wilfred Martinez, 47, sold some of the booty to a jeweler in the same building where he found them, but not the 17-carat diamond that was the $3.2 million crown jewel of the collection, the sources said.

He has now turned over that piece to cops, along with two smaller diamonds and $10,000 in cash.

Click for more from the New York Post.