A man accused of secretly wedding a woman while already married was not breaking the law as the first ceremony was a sham, a court heard.
Iain Theyers, who denies bigamy, re-married in 2011 while wedded to Marian Belahonia, of Peru, prosecutors allege.
Ms Belahonia, who wanted to file for divorce, discovered through Facebook he had re-married, Hull Crown Court heard.
But Mr Theyers, of Inverness, claims their marriage in 2006 in Peru, was a sham to enable her to get a UK visa.
Prosecuting barrister Gordon Stables told the jury Ms Belahonia, 38, met Mr Theyers when she moved to Nottingham, where he was then working as a manager at Robin Hood Airport.
The couple married at her parent's home in Peru, while pregnant with his child and returned to live in Britain, the jury was told.
Mr Stables said: "The defendant knew he had entered into valid marriage."
He said the couple had a son together, but their marriage deteriorated four years later and he moved out.
Ms Belahonia became suspicious after Mr Theyers, 45 and of Balloch Farm, Balloch, "vanished" and "all contact ceased... with his son", the jury was told.
The court heard she tracked him down on Facebook in an effort to file for a divorce, but then discovered he had married Louise Martin in 2011, but had failed to declare his marriage to her to the registrar at Bridlington Town Hall.
But defence barrister Glenn Parsons told the jury Ms Belahonia had originally pressured Mr Theyers into marriage, to enable her to get a visa to stay in the UK, and Peruvian legal procedures were not followed.
In cross-examining Ms Belahonia - who was granted full UK citizenship in 2013 - Mr Parsons said she paid $50 to "a man in the street with a brown envelope" to obtain a marriage certificate.
"Your parents knew the Mayor and encouraged him to arrange a quickie marriage in your living room and all formalities were ignored," he said.
"This whole marriage was a sham - from start to finish - cooked up, by you and your family.
"You knew all along it was not legally binding."
The trial continues.