Israel's defense minister announced his resignation on Friday, saying the governing party had been taken over by "extremist and dangerous elements" and that he no longer trusted Prime Minister Benjamin Netanyahu following reports that he was to be replaced.

Moshe Yaalon's departure removes a strong voice of moderation in the Cabinet and deepens the rift between the security establishment and the hardline politicians.

Yaalon told reporters that "Israel is a healthy society" with a "sane majority" that is tolerant of minorities and strives for a liberal and democratic society.

"But to my great dismay extremist and dangerous elements have taken over Israel, also over the Likud party, and are shaking the house and threatening to hurt its inhabitants," he said. "I fought with all my might against manifestations of extremism, violence and racism in Israeli society that threatens its sturdiness and is seeping into the army and already damaging it."

Yaalon said earlier he told Netanyahu that "following his conduct in recent developments and in light of the lack of trust in him, I am resigning from the government." He added in a Facebook post, that he was also resigning from Israel's parliament and was "taking a time out from political life."

Yaalon and Netanyahu have repeatedly butted heads over the role of the military in public discourse. Netanyahu was enraged earlier this month when a senior officer made public comments viewed as critical of the government, while Yaalon backed the general's right to freely express his views.

Yaalon said he always put Israel's security and other interests above his own, but "unfortunately I found myself lately in tough disputes over moral and professional issues with the prime minister and several ministers and members of parliament."

Tensions between Yaalon and Netanyahu escalated in March, when military leaders criticized a soldier who was caught on video fatally shooting an already-wounded Palestinian attacker. The solider is now on trial for manslaughter. While Yaalon has backed the military, hard-liners have backed the soldier.

Reports over the past few days indicate that Netanyahu intends to appoint former foreign minister Avigdor Lieberman to the post of defense minister. Lieberman, 57, is one of the country's most polarizing politicians. Over three decades, he has at times been Netanyahu's closest ally and at other times a fierce rival.

Netanyahu said he regretted Yaalon's decision and that he would have preferred him to stay on as foreign minister. The prime minister also said the political shakeup was not because of differences with Yaalon but out of the need to widen the coalition to "bring stability to Israel against the big challenges it faces."

He said the military "will continue to preserve the highest moral standards" and added that the army must remain outside of politics. "In a democracy the military echelon is subordinate to the political echelon and not the reverse," Netanyahu said.

Netanyahu this week invited Lieberman's ultranationalist Yisrael Beteinu party to shore up his shaky parliamentary coalition and negotiation teams have been meeting to hammer out the details of their alliance.

Yaalon's resignation solidifies the takeover of hard-liners in the party.

Cabinet Minister Gila Gamliel said that Yaalon's leaving was a "tremendous loss" for the ruling Likud. She told Israel Radio she believes it was a "mistake" not to offer Yaalon another position and keep him in the coalition.

Many Israelis have questioned the wisdom of appointing Lieberman to the sensitive post of defense minister over Yaalon, a former army chief of staff who is generally respected for his knowledge of military affairs. Lieberman has no such military experience, though he has held a number of Cabinet posts in the past, including stints as foreign minister.

His hard-line stance has made him an influential voice at home but has at times alienated Israel's allies overseas. He has questioned the loyalty of Israel's Arab minority and confronted Israel's foreign critics. He has expressed skepticism over pursuing peace with the Palestinians, and is now pushing a proposal to impose the death penalty against Arabs convicted of acts of terrorism.

With Israeli-Palestinian peace efforts stalled, Lieberman's addition to the government could push the prospect of reviving talks even further away.

Yaalon's departure also paves the way for Yehuda Glick — an Israeli-American activist who campaigns to allow Jewish prayer at Jerusalem's holiest site, sacred to both Jews and Muslims — to enter the government. Any perceived change to the status quo that bans Jews from praying at the site has sparked Palestinian violence in the past.

The hilltop compound in Jerusalem's Old City is revered by Jews as the Temple Mount, site of the two Jewish biblical Temples. It is the holiest site in Judaism. Known to Muslims as the Noble Sanctuary, it houses the Al-Aqsa Mosque and the gold-topped Dome of the Rock. It is the third-holiest site in Islam after Mecca and Medina in Saudi Arabia.

Tensions over the site erupted in September and months of bloodshed followed with dozens of Palestinian attacks on Israeli civilians and security personnel. Since then, Palestinian attacks, mostly stabbings, shootings and vehicular assaults, have killed 28 Israelis and two Americans. About 200 Palestinians have been killed during that time, most of whom Israel says were attackers.

Glick survived an attempt on his life in 2014 when shot several times by a Palestinian.