SYDNEY, Australia — Barnaby Joyce officially resigned Monday as Australia’s deputy prime minister, clearing the way for a replacement — Michael McCormack, the veterans affairs minister — who was named to the post in an awkward news conference that included Mr. Joyce sulking in the back of a National Party gathering he had grown used to leading.

It was an embarrassing public comedown for Mr. Joyce, a brash conservative closely identified with the country’s rural voters. He has been battling scandals that started earlier this month with his admission of an affair with a former staff member, who is pregnant with his child.

His trouble continued with accusations of misspending of public funds, in part to abet that relationship, along with at least two separate accusations of sexual harassment that have stirred up demands for a #MeToo reckoning across Australian politics.

Mr. Joyce has repeatedly denied any wrongdoing. He has said he plans to stay in Parliament. But questions about his behavior continue to swirl.