A former police officer who had sex with a woman and allowed her to handle his gun at a police station has been sentenced to 20 months' imprisonment but is being assessed for an intensive correction order.

Mark Garner appeared before a Sydney court on Thursday after pleading guilty to two counts of misconduct in office.

Used during a sexual encounter: A Glock.

Garner, 50, from the NSW Far North Coast, began a relationship with the woman after she went to Tweed Heads police station in June 2011 to say she had been sexually assaulted.

The former detective sergeant then had sex with the woman and used his Glock pistol as a sex toy during their intimate encounter.