Robert Norman, 54, is charged with misconduct in a public office while working at Belmarsh, a top-security prison in south-east London.
He was allegedly paid more than Â£10,000 for 40 tips to reporter Stephen Moyes between 30 April 2006 and 1 May 2011.
Mr Norman, of Swanscombe, Kent, denies the charge against him.
Opening the case at the Old Bailey, prosecutor Julian Christopher QC said Mr Norman was an "extremely experienced" prison officer and a member of the Prison Officers Association, acting as union representative to colleagues.
The court heard Mr Norman first phoned the Daily Mirror in 2006 and gave Mr Moyes a story about staff cuts at the prison, for which he was paid Â£400.
The exclusive story described Belmarsh as a "terror prison" and ran alongside a photograph of one of its most notorious prisoners, radical preacher Abu Hamza al-Masri, the court heard.
As the relationship developed, it became a "two-way affair" and Mr Norman carried on dealing with Mr Moyes when the journalist moved to the News of the World, the court heard.
Mr Christopher said: "Sometimes Robert Norman would approach Stephen Moyes with something he thought would be of interest, at other times Stephen Moyes would approach Robert Norman for inside information about a topic in which he was interested, or for confirmation which he would not be able to get for free from the official channels at the Ministry of Justice press office.
"Effectively, Robert Norman became the journalist's paid mole within HMP Belmarsh."
The court heard that when Mr Norman was arrested in 2013 he maintained he had acted in the public interest as a whistleblower.
Cheques for the stories were made out to Mr Norman's son Daniel and the money was then transferred into Mr Norman's account, showing he was "worried about the trouble he would get into" if found out, Mr Christopher said.
The trial continues.
A prison officer became the "paid mole" of a reporter working at the Daily Mirror and News of the World over five years, a court has heard.