LONDON (AP) — An adviser to British Prime Minister Boris Johnson resigned on Monday amid fierce criticism of his past comments linking intelligence to race and suggesting contraception should be made compulsory to avoid “a permanent underclass.”

Andrew Sabisky said he was quitting because he had become “a distraction.”

Lawmakers from both the opposition and the governing Conservatives had called on Johnson to fire Sabisky, who was hired to work in the prime minister's 10 Downing Street office after Johnson’s chief aide, Dominic Cummings, appealed for “weirdos and misfits with odd skills” to apply for government jobs.

Sabisky — who has a master's degree in the psychology of education, according to an online biography — wrote in 2014 that “one way to get around the problems of unplanned pregnancies creating a permanent underclass would be to legally enforce universal uptake of long-term contraception at the onset of puberty. Vaccination laws give it a precedent, I would argue."

He has also suggested that black Americans have a lower average IQ than white Americans.

The comments were condemned by Johnson's opponents, as well as some allies.

Lawmaker Caroline Nokes, a member of Johnson’s Conservative Party who chairs Parliament’s Women and Equalities Committee, tweeted: “Cannot believe No 10 has refused to comment on Andrew Sabisky. I don't know him from a bar of soap, but don't think we'd get on ... must be no place in government for the views he's expressed.”

Scottish First Minister Nicola Sturgeon said Johnson's government needed "to get a grip fast and demonstrate some basic but fundamental values in the terms of our public debate.”

On Twitter, Sabisky accused critics of “selective quoting" and said “I signed up to do real work, not be in the middle of a giant character assassination.”

“The media hysteria about my old stuff online is mad but I wanted to help (the government) not be a distraction. Accordingly I've decided to resign as a contractor," he wrote.

Earlier Monday a spokesman for Johnson declined to discuss Sabisky’s role in Downing Street, saying "I'm not going to be commenting on individual appointments."

Spokesman Jamie Davies also refused to say whether the prime minister agreed with Sabisky’s views, which critics say amount to support for eugenics, the now-discredited movement to improve the human race through selective reproduction.

"The prime minister's views on a range of subjects are well publicized and documented,” Davies said.

Johnson has his own record of offensive comments. He has called Papua New Guineans "cannibals," referred to people in Commonwealth countries with the offensive term “picaninnies” and said the children of single mothers were "ignorant, aggressive and illegitimate."

The episode is the latest controversy connected to Cummings, a self-styled political disruptor who helped mastermind the successful Vote Leave campaign in Britain's 2016 European Union membership referendum. He took up his powerful role as Downing Street adviser after Johnson became prime minister in July.

Last month, Cummings put out a call on his blog for “super talented weirdos” to join the government and expand its roster of talent.

"We need some true wild cards, artists, people who never went to university and fought their way out of an appalling hell hole, weirdos," he wrote.