Melissa Priestley, 33, fell for violent robber Leonie Kinnish, from Lancaster, at HMP Low Newton, Durham, and gave her special privileges, angering other inmates.
Their affair was uncovered by authorities after inmates saw them kissing, and Priestley was suspended from her job after almost 10 years’ service, Durham Crown Court heard.
Paul Reid, prosecuting, said rumours began circulating about the pair and Kinnish, who was serving five years, had her cell searched.
Letters from the prison guard to the inmate were found, speaking of her “very considerable affection”.
Mr Reid said: “It would appear from the content of the letters that the affection was reciprocated.”
Messages on Priestley’s phone to another prison officer corroborated she was having an affair.
The relationship started in October last year and was discovered the following month.
Mr Reid said Kinnish refused to help with the inquiry but other prisoners said they saw “the defendant and the prisoner kissing and fondling each other”.
Priestley was also accused of allowing Kinnish to be out of her cell for longer than allowed, despite her being punished on “basic privilege” which should only give prisoners one hour out in every 24.
When others complained, Priestley allowed them to be out longer than an hour too, the court heard.
Mr Reid said on one occasion Kinnish was seen to lift up her top and expose her breasts to the defendant.
Priestley was said to have locked up Kinnish last at night, and brought her small gifts.
Ros Scott Bell, defending, said these were “trinkets of the heart” - sweets or earrings - and nothing illegal was handed over.
Miss Scott Bell said nothing more than kissing had taken place, and there was no intimate sexual relationship.
“It shows a degree of restraint on behalf of the defendant,” she said.
Priestley hoped things would develop further when Kinnish was released, the court heard.
The barrister added: “She’s extremely remorseful for what she has done. This is a case where her heart was put before her judgment.
“She knew the relationship to be prohibited. What she would say is she couldn’t help herself.
“This was not a situation where she deliberately sought someone out, it was a mutual attraction.”
Priestley, from Newton Aycliffe, County Durham, was suspended in November and resigned in March. Since then she has worked 48 hours a week in a factory and set up her own beauty business.
“She wants to better herself, she has much to offer society,” Miss Scott Bell said.
Kinnish was moved to Styal Prison in Manchester after the affair was discovered. She was jailed in 2005 for pushing over a woman in her own flat and taking money from her. She had previously served a four-year sentence for an unprovoked street assault with a hammer.
Judge Simon Hickey gave Priestley credit for her guilty plea to misconduct in public office, her “impeccable character” up until her conviction, and her hard work.
But he said he could not suspend her jail sentence, adding: “It’s just too serious.”