Former assistant police commissioner Brett Guerin has told a court he made racist and obscene posts under online pseudonym Vernon Demerest as a way of dealing with the stress and anxiety of his senior role in the force.

Giving evidence in a defamation trial before the Supreme Court, Mr Guerin told jurors he had created a character or persona that was a "pretentious bigot" in order to post the messages that led to his shock resignation from Victoria Police in February 2018.

In his first explanation of the online posts, which included suggesting the "jigaboo ... needs the lash" and describing Argentine soccer players as "greasy, diving, cheating dagoes", Mr Guerin told jurors the words did not reflect his views and that the Demerest traits were instead appropriated from fictional characters in books he had read.

Former Victoria Police superintendent Brett Guerin leaves the Supreme Court on Thursday. Credit:Chris Hopkins

Mr Guerin is the subject of a Supreme Court trial launched by nightclub owner Martha Tsamis, who claims her reputation was ruined when Mr Guerin described the King Street venue as a "honeypot" for drug dealers in interviews with the Herald Sun and 3AW in 2014. The defendants are Victoria Police and the state government.