(Getty)

Sir Ian McKellen has used his first visit to India to raise the country’s stance on homosexuality.

Speaking to Scroll, McKellen said: “You have a repressive law in place for which I should apologize, because it’s not an Indian law, it’s a British law that we left behind.

“You should have got rid of it, and you tried to, and it’s come back, but it will go again, I’m sure.”

As part of his global tour as ambassador for the British Film Institute’s Shakespeare on Film program, the actor spoke on-stage to Bollywood star Aamir Khan.

Again addressing the law, he said: “We changed [our laws] long back in England, but you are holding on to it to protect yourselves from western culture,” reports the Indian Express.

Sir Ian also told the Mumbai Mirror that “India needs to grow up”.

He said: “India is going through what the UK went through 30 years ago. It is appalling and ironical that India would use a colonial law to oppress its homosexuals. India needs to grow up. India needs to realise that it doesn’t need to follow British laws any more.”

The actor is referring to India’s Section 377, a gay sex ban which was introduced in 1862 under British rule.

The colonial-era law was reinstated by the Supreme Court in 2013.

The law criminalises sexual activity “against the order of nature” and can result in a maximum life sentence.

Modi’s Hindu nationalist Bharatiya Janata Party MPs has consistently resisted bids to repeal the law, and in March a private member’s bill on the issue was voted down by a vote of 58 to 14.