A Miami man in town for his father’s funeral tried to bring a gun through Newark Liberty International Airport security earlier this week.

He claimed he didn’t know how the unloaded handgun made its way into his carry-on bag, authorities said on Wednesday.

The man, Thomas Lewis Goldsmith, was caught Monday when a TSA officer spotted the .38 caliber gun through the X-ray machine, according to the agency.

It was wrapped in a scarf and inside a leather holster belt clip, according to a Port Authority spokesman.

Goldsmith allegedly told officials that he had collected some of his dad’s personal items to take home with him, but didn’t know how the gun made it to the airport, according to the TSA.

The agency allows unloaded firearms to be carried in locked hard-sided containers as checked baggage, but not in carry-on bags.

Goldsmith was charged with unlawful possession of a weapon and held in lieu of $25,000 bail.

He is also subject to civil penalties from TSA of up to $12,000, according to the agency.