Code violation is a separate issue. Even if the city got involved and gave you a fine, the amount usually would be rather small(comparing with a couple of month's rent). But the tenant got to pay by the lease. You should not yield to him. Have a lawyer as miat42 said and make sure you win this one.
In the mean time, take steps to acquire necessary permit to rent as a multi-family unit(you may not be able to get it zoned as multifamily if it has been classified as single since a long time ago). That's why it is important to do homework yourself before buying a house as realtor information is often incorrect.