SYDNEY, Australia — Australia’s deputy prime minister, under fire over his affair with a former staff member, defied pressure to resign on Friday and said Prime Minister Malcolm Turnbull’s sharp criticism of him had been “inept” and “unnecessary.”

Deputy Prime Minister Barnaby Joyce’s remarks came a day after Mr. Turnbull banned sex between government ministers and their subordinates in response to the scandal. Mr. Turnbull said on Thursday that Mr. Joyce — head of the National Party of Australia, the junior partner in his coalition government — had made “a shocking error of judgment” by having an affair with an aide, who is now pregnant.

“In doing so, he has set off a world of woe” for the women involved, Mr. Turnbull said, including Mr. Joyce’s wife and daughters. The prime minister stopped short of asking Mr. Joyce to resign, but said he would take a leave.

On Friday, Mr. Joyce rebuked Mr. Turnbull’s criticism and said the prime minister’s remarks had “caused further harm.”