BELGRADE (Reuters) - A court in Montenegro ordered a journalist to serve four months in prison for libel on Wednesday in a case that could damage the country's reputation for media freedom as it prepares for talks on joining the European Union.

The case stems from a 2007 report in the Montenegrin weekly Monitor in which journalist Petar Komnenic alleged that authorities in the Adriatic country had placed a number of senior judges under illegal surveillance.

Komnenic was convicted of libel in February 2011 and ordered to pay a fine of 3,000 euros ($3,900) or serve four months in jail.

He refused to pay the fine and appealed to a higher court, which ruled he should serve community service rather than a prison sentence. But the Podgorica magistrate on Wednesday reinstated the prison term.

Rights groups in the former Yugoslav republic have expressed concern over the handling of the case. One of the judges cited in the report testified to the alleged surveillance and court files containing evidence went missing.

Komnenic is an editor with Podgorica-based TV Vijesti and also works as a stringer for Reuters.

The European Union has said it is following the case, and stressed that media freedom in Montenegro is a concern as it nears the start of accession talks in June this year. A spokesman for EU Enlargement Commissioner Stefan Fuele was not immediately available for comment.

Montenegro last year decriminalized libel as part of a string of reforms to clinch accession talks, but the change came after Komnenic's conviction.

Komnenic's lawyer, Veselin Radulovic, said he had appealed to the Montenegrin High Court. He said Komnenic could also ask for a pardon from Montenegrin President Filip Vujanovic.

"But he won't do that," Radulovic said, "And I fully understand his motives as he is a journalist and was doing his job, working in the interests of the public."

Montenegro, a country of 680,000 people struggling with deep-rooted organized crime and corruption problems, ranks 107 out of 179 countries in the world press freedom index compiled by media watchdog Reporters Without Borders.

(Reporting by Aleksandar Vasovic and Matt Robinson; Editing by Michael Roddy)