brooks coulson
Andy Coulson and Rebekah Brooks deny all the charges against them(Getty)

Former News of the World editor Andy Coulson has described his affair with Rebekkah Brooks as "wrong [and] should not have happened".

Coulson, 46, was giving evidence for the first time at the Old Bailey phone hacking trial when he apologised to his wife for his relationship with the former News International chief executive.

He denied the affair lasted for six straight years but said it occurred "in brief periods" from 1998.

Brooks had previously told the court about their affair while she spoke of her "car crash" personal life.

Coulson told the court: "There was an affair starting in 1998. It ended quite soon afterwards but it did restart as the court has heard.

"What I want to say is that it was not by any means continual. There were very long periods where the relationship was what it should have been [just friends].

"But I don't want to minimise it or excuse it. It was wrong and it shouldn't have happened and I take my full share of responsibility for the pain it has caused other people, not least my wife."

Coulson, who worked as David Cameron's spin doctor after quitting NotW in 2007, told the jury he has not spoken to the prime minister for three years.

Coulson said he and his family spent a weekend with Cameron after he resigned from his role as Tory director of communications but that the invitation was issued before he quit in 2011.

Coulson was arrested on suspicion of phone hacking six months after leaving government.

"Immediately after [my resignation] my family and I spent a weekend with him [Cameron] in the spring after I left," he said.

"I haven't spoken to him since."

Coulson also told the Old Bailey he had "sparing" contact with Rupert Murdoch since he quit his newspaper in 2007 following the conviction of its royal editor Clive Goodman on phone hacking charges.

"Almost entirely at social occasions, then there were also occasions while David Cameron met Rupert Murdoch and, although I did not sit in on those meetings, I saw him either before or after," he said.

Coulson in one of seven people, including Brooks, on trial for phone hacking charges. All defendants deny the charges.

The trial continues.