The sub-judge Kannan also slapped a fine of Rs 5,000 on the accused.
The prosecution case was that the farmer had repeatedly raped the Class VIII girl in September 2008 when she used to go out to graze her cattle during school holidays and also threatened her with dire consequences if she revealed the matter to anyone.
The girl revealed her plight to her teachers at the government school and was admitted to a woman's home after her parents refused to take care of her. She gave birth to a baby boy, who died soon after, officials said.
On a complaint from Assistant Educational Officer, police had registered a case, but there was no follow up as there was none to support the girl, they said.