LONDON — Prime Minister Theresa May of Britain, trying to pacify her Conservative Party after a major setback in the country’s election on Thursday, on Saturday let go her top two aides, who had earned reputations for secrecy and arrogance.

The aides, Fiona Hill and Nick Timothy, Mrs. May’s co-chiefs of staff, resigned after reports that senior Conservative ministers in the prime minister’s cabinet had warned her that they would challenge her leadership of the party unless she became more inclusive, consulted more widely and fired Ms. Hill and Mr. Timothy.

When she became prime minister, Mrs. May brought the two loyal aides with her from the Home Office, which she had run for six years. She relied heavily on them, and they were fiercely protective of her but offended many.

Ms. Hill is well known for her aggressive treatment of senior ministers and Downing Street staff, while Mr. Timothy is considered responsible for shaping the Conservative election platform, which proved so unpopular with voters that one Conservative member of Parliament, Nigel Evans, said, “We didn’t shoot ourselves in the foot; we shot ourselves in the head.”