Lawyer Andrew Edis told London's Old Bailey court that the pair were lovers from at least 1998 to 2004, which includes the period they worked together at the Rupert Murdoch-owned tabloid.
Edis said the relationship was laid bare in a 2004 letter found on Brooks' computer and insisted it was directly relevant to the charges against them of conspiracy to hack phones.
"It is clear from that letter that, as of February 2004, they had been having an affair which had lasted at least six years," he told the jury.
He added: "Mrs Brooks and Mr Coulson are charged with conspiracy and, when people are charged with conspiracy, the first question a jury has to answer is how well did they know each other? How much did they trust each other?"
Also Read
"And the fact that they were in this relationship which was a secret means that they trusted each other quite a lot with at least that secret and that's why we are telling you about it."
Murdoch was forced to shut down the News of the World in July 2011 amid a storm of revelations that it had illegally accessed the voicemail messages of a murdered schoolgirl as well as hundreds of celebrities.