Mr Netanyahu summoned Mr Gallant to a meeting and told him he no longer had faith in him as defence minister.
The plan to limit the powers of the judiciary has led to months of public protests.
Mr Gallant had called it an “immediate and tangible danger” to state security.
In a brief televised statement on Saturday night, Mr Gallant said members of the Israeli Defence Forces were angry and disappointed, with an intensity he had never seen before.
Shortly after his dismissal a day later, Mr Gallant wrote on Twitter: “The state of Israel’s security has always been and will always be my life’s mission.”
The defence minister had won the backing of some fellow members of Mr Netanyahu’s Likud party, but others on the far right had called for him to go.
Protests against the changes to the legal system continued on Sunday night, with demonstrators blocking a major road in Tel Aviv.
The law is part of the right-wing coalition government’s contentious plan to limit the powers of the judiciary.
Far-right national security minister Itamar Ben-Gvir supported Mr Netanyahu’s move, saying,”The prime minister decided on the necessary step and I congratulate him for that.”
It includes enabling parliament to overrule decisions made by the Supreme Court – a move that critics say will undermine the independence of the judiciary and could be used for political ends.
But Mr Netanyahu says the reforms are designed to stop the courts overreaching their powers and that they were voted for by the public at the last election.
Israel’s opposition leader Yair Lapid described Mr Gallant’s sacking as “a new low” for the government.
“Netanyahu can fire Gallant, but he can’t fire reality or fire the people of Israel who are fronting up to resist the coalition’s madness,” Mr Lapid added.
Former defence minister Benny Gantz praised Mr Gallant, who he said had put the security of the country above all interests.