Put down that coffee, and come out with your hands up!

The owner of a Financial District tobacco shop was amazed to learn he was violating the law by offering his customers a free cup of joe while they legally puffed away on his cigars.

Vince Nastri III, the third-generation owner of Barclay Rex — where bankers, City Hall staffers, lawyers and detectives smoke while sitting in plush leather chairs or browsing in the walk-in humidor — complained that the city is “trying to take away my livelihood over a cop of coffee.”

Health officials had no problem with all the cigars his customers were puffing on — a handful of businesses, including Nastri’s, are exempt from Mayor Bloomberg’s anti-smoking laws — but decided a $9,000 coffee machine was grounds for closing the place down.

“We didn’t survive in business for 99 years by breaking laws. But this is just petty,” said Nastri, whose shop’s past customers have included Frank Sinatra, James Cagney and former Mayor Rudy Giuliani.

Nastri first got into hot water on June 10, when Health Department inspectors arrived at his shop, at 75 Broad St., to check out a complaint that cigar odor was wafting to the building’s upper floors.

The inspectors decided the complaint was unfounded. But one inspector pointed out the coffee machine, which customers used gratis to make themselves espressos, lattes and cappuccinos.

“That’s illegal,” the inspector pronounced — and issued Nastri a citation, which can lead to fines ranging from $200 to $2,000.

Nastri found himself in a classic Catch-22 situation.

To serve coffee — even free coffee — he needs a permit to operate a food-service establishment. But smoking is banned in food-service establishments.

Realizing that resistance would be futile, Nastri had the machine removed.

“It’s like the city has nothing better to do than worry about me providing my customers with coffee?” Nastri said.

Bill Flynn, a customer who saw the first citation being issued, said, “The government thinks it knows better than everybody; that’s the problem.”

Michael Mitchell, a recent customer who had to bring in his own takeout coffee from a nearby store, groused, “I’m upset [the machine] is gone. I had to pay two bucks for this, when it used to be right here.”

dan.mangan@nypost.com