NEW DELHI — After a legal battle that lasted nearly 20 years, a prominent Bollywood actor once seen by many as above the law was convicted of poaching two endangered blackbuck antelopes and sentenced to five years in prison.

Salman Khan, a 52-year-old baby-faced leading man, was accused by members of the Bishnoi religious sect in western India of shooting at a group of rare black-and-white antelope on a hunting trip while filming a movie in 1998.

The verdict comes as a surprise to many who say Khan’s connections got him out of trouble in the past. The actor was previously acquitted of two separate poaching cases and of a hit-and-run manslaughter charge in 2015.

“There’s a sense in India that the rich and mighty can get away from the law. … Today, finally there’s a sense of justice being done,” said one news anchor as she announced the verdict.

Khan’s fans thronged outside the courtroom hoping to catch a glimpse of the actor on his way in, and police ramped up security, Indian media reported.

Known in Bollywood as “bhai,” meaning “brother,” Khan has made a career playing larger-than-life characters who often overcome near-impossible challenges. His one-liners are often quoted by fans, who whistle and sing along to his dance numbers in movie theaters.

In the early 2000s, he was known for being rude and aggressive to co-workers and media, and his career was dogged by allegations of bad behavior. In a famous incident, one of his ex-girlfriends, Somy Ali, said he had once poured a bottle of Coke all over a table because he didn’t approve of her friends. He was also accused of abuse by ex-girlfriend, Aishwarya Rai, a leading Bollywood actress. The tarnishing of Khan’s image took its toll at the box office while he was starring in big-ticket films.

Then in 2008, he rebranded. He launched a charity called Being Human — The Salman Khan Foundation that took on various health and education initiatives and was seen participating in philanthropic activities. The image revamp worked, and Khan soon built up a die-hard fan following, with successive films breaking box-office records.

But the blackbuck poaching case — which trundled through India’s slow-moving legal system throughout Khan’s career highs and lows — continued to be a reminder of Khan’s past.

The incident happened in 1998, when Khan and his co-stars were out on a hunting trip in the western state of Rajasthan while filming the blockbuster movie "Hum Saath Saath Hain.” His co-stars in the film were present in court for the verdict but were acquitted because of a lack of evidence.

Khan’s accusers from the eco-loving Bishnoi sect supposedly chased his car and found carcasses of the rare antelope in the forest. Ram Nivas, a member of the sect, told NDTV that the court had been too lenient with Khan’s co-stars, who were also in the car with him when the incident happened.

“Justice was delayed for 20 years," Nivas said. "They have used every loophole to escape from the laws. The others should not be released: We will ask the government to file a case against them also.”

Khan’s lawyers are likely to appeal the verdict and apply for bail.