Dr Benjamin Carson, a neurosurgeon with Johns Hopkins University and a conservative speaker, has pulled out of appearing as commencement speaker at the school’s diploma ceremony.

He previously apologised for comments made on Fox News comparing gay people to a pedophilia advocacy group, as well as to bestiality.

In March Dr Carson appeared on Fox News, and told the show’s host, Sean Hannity: “My thoughts are that marriage is between a man and a woman. It’s a well-established, fundamental pillar of society and no group, be they gays, be they NAMBLA (North American Man/Boy Love Association), be they people who believe in bestiality–it doesn’t matter what they are–they don’t get to change the definition.”

The Associated Press reported that, in a letter written to the dean of the medical school, Carson said he did not want to become a distraction from the ceremony.

The remarks on Fox sparked outrage due to the apparent comparison of same-sex marriage to pedophilia and bestiality.

Students at Johns Hopkins University, where Dr Carson was scheduled to give a commencement address, arranged a petition for him to be pulled from the role.

On Friday Mr Carson wrote a letter to the University apologising for the negative attention his comments had brought and expressing sadness at the pain caused by “poorly chosen words”.

The same day Dr Paul Rothman, the University Medical School’s dean, said Dr Carson had the right to express his opinion, but added: “We recognize that tension now exists in our community because hurtful, offensive language was used.”

Mr Carson became popular in conservative political circles after he spoke out against Obamacare at the National Prayer Breakfast, a high-profile event attended by President Obama.

Last month, a group of top US paediatricians announced its endorsement of equal marriage, as a way of ensuring that children receive security and benefits in their upbringing.

The American Academy of Pediatrics (AAP), which is well-known, and the opinions of which are considered influential by many, went on to endorse full adoption and foster care rights for all parents, irrespective of sexual orientation.