Leslie Turner, 54, of Cromwell Hill, Luton, pleaded guilty at Luton Crown Court to attempting to meet a child following sexual grooming.
He thought he was meeting a 14-year-old girl for sex but instead was met by three people who had set up a fake internet profile to catch paedophiles.
Police have urged the public not to take the law into their own hands.
Luton Crown Court heard Turner believed he was going to Luton railway station to meet a teenager called Lisa Fisher, but she had been created by people purporting to be from a group called the Anonymous Network.
Prosecutor Neil King said they were "members of the public who are trying to discover members of the public who are paedophiles".
During Facebook chats, Turner told the fake girl he was old enough to be her grandfather and made the first reference to sex by asking her about her favourite position.
The "girl" also sent him two indecent photographs.
He arranged to meet her in July, promising her he would not pressurise her into having sex.
When he arrived, he was met by Neil Ivall and two women wearing Guy Fawkes' masks, who detained him and seized his phone. He was then arrested.
Defence barrister Ross Talbott said Turner was a "lonely individual who was having online relationships".
Bedfordshire Police's Alex House said: "While we are pleased that this case has resulted in a potential offender being locked up, we would urge people to never take the law into their own hands."
Turner must register as a sex offender for 10 years and abide by an order which bans him having contact with children in person or over the internet.
A man has been jailed for 14 months after being caught by masked paedophile hunters when he went to a "sting".