A Conservative candidate caught on video staging a supposedly impromptu encounter with a constituent was previously the subject of an internal party complaint for posting a sexist comment on Facebook, the Guardian has learned.

Lee Anderson, who is standing in the key Tory target of Ashfield, in Nottinghamshire, was exposed by the reporter Michael Crick on Monday after setting up a canvassing encounter with a longtime friend.

Now the Guardian has established that Anderson, a leave supporter who defected from Labour, has previously faced allegations in both main parties of holding sexist views.

The Conservatives were asked by an MP to examine a Facebook post by Anderson in July 2018. It showed a photo of Anderson looking at the chest of a female canvasser in a vest top. He captioned the photo: “Out with some great knockers tonight in Skegby.”

Anna Soubry, who was then the Conservative MP in the neighbouring constituency of Broxtowe, was made aware of the post and complained to the then party chairman, Brandon Lewis, and other senior officials.

“Lee is an odious sexist,” said Soubry, a remainer who is standing as an independent. “I complained to the highest level of the Conservative party about Lee and his Facebook posting. I specifically spoke to Brandon Lewis and a very senior party worker and I sent a copy of the Facebook posting to another very senior party official. So there is no way they can say that they did not know about this posting many months before he was selected as the candidate.”

Ashfield, a former coalmining community, was once a solid Labour seat but the party’s majority was whittled down to 441 votes at the last election and the area voted heavily to leave the EU.

It is now a three-way marginal between Labour, the Tories and a local independent group.

Anderson, 52, a former miner and Labour councillor, spent the last election working as campaign manager for the outgoing Labour MP Gloria de Piero.

He joined the Tories in March last year and was chosen a few weeks ago to stand as their election candidate.

Anderson was interviewed as a potential Labour district councillor a few months before he joined the Tories but was rejected after making comments in the interview that were alleged to be sexist.

He allegedly told a three-person panel that women could not be councillors because of childcare responsibilities. Marje Paling, a member of the panel, said: “He did not seem to be aware that it might be offensive.”

Anderson has fallen out with many of his former comrades in the local Labour party. Anne Ayres, the branch secretary for Sutton West in Ashfield, who worked closely with him, said: “He doesn’t engage his brain before opening his mouth.”

It emerged on Monday that Anderson was caught by Crick phoning a friend and saying: “I’m knocking at your door in a minute. You know I’m the candidate but I’m not a friend, all right? I’ll see you in a minute.”

Later, when apparently canvassing, Anderson knocked on the door of a constituent called Steve whom he admitted that he recognised. Steve told Anderson: “I will be going with you. There is no way Labour will ever get my vote.” Crick told Anderson that the interview felt staged.

Later, when reviewing footage, Crick’s producer realised they had video and audio of Anderson speaking to the constituent on the phone, arranging the door-knock and what they would say.

Anderson did not respond to a telephone call and a text.

The Conservatives have been asked to explain why Anderson was chosen as a candidate and if they had thoroughly investigated Soubry’s complaint.

Conservative sources said the party received no formal complaint but Anderson was warned about his conduct.