Gentleman usually meant someone who didn't have to work for a living. They didn't have to be upper class, just have enough income not to have to work. It was sometimes used by men who'd retired from a profession or who'd done well in trade.
I have an ancestor who migrated, and on his trip home upon retirement it says Gentleman in the occupation column of the passenger list. Before retirement he ran a baker's shop and his father had been an ag lab.