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.

The Norway international, 29, was substituted in the 36th minute of Tuesday's 2-1 home defeat by Chelsea after a collision with Eden Hazard.
"It's not good news but we have got strength in depth in midfield," Neil said before Saturday's trip to Swansea.
The Canaries are 18th in the Premier League after an eight-game winless run.

Energy Minister Fergus Ewing refused permission for the 21-turbine Rowantree development near Oxton last May.
He said the decision was based on "unacceptable environmental impacts".
RWE Innogy UK has submitted scoping plans to Scottish Borders Council for a wind farm of up to 11 turbines in the same location.
The proposed development on land north-east and east of Burnhouse Mains farmhouse, between Stow and Fountainhall, will be known as Longmuir Rigg wind farm.
A letter lodged with the council states that RWE's new plans for the site take into account the Scottish government's concerns about the Rowantree development.
In the correspondence, project manager Christopher McPake states: "It has sought to reduce or negate the identified significant environmental effects of cumulative noise as well as effects upon landscape character and visual receptors."
It lays out plans to build between nine and 11 turbines, no more than 130m (426ft) high.

Police Scotland said they had searched four properties and had seized drugs worth about Â£65,000 and a four-figure sum of cash.
An air weapon was also recovered during the operation. The drugs seized are believed to be cocaine.
Three men, aged 65, 38 and 18, and two women, aged 68 and 39, were arrested for alleged drugs offences.
They are expected to appear at Paisley Sheriff Court on Monday.
A 64 year-old woman and a 66 year-old man will also be subject of a report to the procurator fiscal in connection with the air weapon.
Officers said they had searched homes in Cameron Avenue in Bishopton, Ryat Linn and Sconser in Erskine, and Merlinford Crescent in Renfrew at about 15:30 on Friday.
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.
[NEXT_CONCEPT]
Norwich midfielder Alex Tettey needs ankle surgery and is likely to miss the rest of the season, says Canaries manager Alex Neil.
[NEXT_CONCEPT]
Plans have been lodged for a wind farm in the Scottish Borders less than a year after the Scottish government rejected a scheme for the same site.
[NEXT_CONCEPT]
Five people have been arrested after a series of drugs raids at homes across Renfrewshire.