Malaysia's leader Anwar Ibrahim has said his nation will maintain ties with Hamas and will "not punish" the group.
Malaysians should "unanimously back" the Palestinian cause, the prime minister told parliament on Tuesday.
Mr Anwar was responding to a proposal by US lawmakers to sanction Hamas's foreign supporters.
Analysts say this is also politically expedient in a country where support for Palestinians has long been bipartisan as well as widespread.
An opposition lawmaker had asked Mr Anwar about the Malaysian government's stand after the US House of Representatives last week voted to sanction foreign supporters of Hamas and the Palestinian Islamic Jihad.
"I will not accept any threats, including this... This action is unilateral and not valid, because we as members of the United Nations only recognise decisions made by the UN Security Council," Mr Anwar said.
Malaysia, a Muslim-majority nation, has long advocated for the Palestinian cause. It does not recognise Israel diplomatically and has maintained that no such recognition will be given until a two-state solution - one for the Israelis and one for the Palestinians - is realised. Its capital, Kuala Lumpur, is a frequent host to conferences on Palestinian issues.
The 76-year-old Mr Anwar has also advocated for Palestinians since his university days. Like in many parts of the world, Israel's retaliatory strikes on Gaza have sparked mass gatherings and prayer rallies in Malaysia.
But it has also led to some displays of support for Hamas. A video of a group of teachers dressed up as militants and toting toy rifles went viral on TikTok during Malaysia's Palestine Solidarity Week at the end of October, prompting Mr Anwar to call on schools to monitor activities during the week.
Mr Anwar's mentor-turned-political rival Mahathir Mohamad, has also made strong remarks in support of the Palestinian cause, calling out other nations for their silence over what he has called "Israeli war crimes".
Mr Anwar therefore cannot afford to be seen as having weak views at a time when religious conservatism is rising in Malaysia, Julia Lau and Francis Hutchinson, researchers at the Singapore-based think tank ISEAS-Yusof Ishak Institute, wrote recently.
The prime minister is also facing decreasing support from the Malay-Muslim community at home. A recent poll by Malaysian think tank Ilham Centre found he only had a 24% approval rating among ethnic Malays. In contrast, he enjoyed 88% ethnic Chinese support and 81% backing from the ethnic Indian community.
Mr Anwar had been criticised before for not taking a stronger stance against Israel. In a 2012 interview, he said Malaysia should "protect the security [of Israel] but be as firm in protecting the legitimate interests of the Palestinians". He later said these remarks were consistent with the two-state solution.
But Mr Anwar appears to be taking a tougher stance in response to the ongoing Israel-Gaza war.
He has rejected Western pressure to condemn Hamas, noting that the group had been elected by Gazans to govern the enclave. At a pro-Palestinian rally last month, he condemned Israeli military action in the Gaza Strip as "the height of barbarism in this world".
On Tuesday, Mr Anwar urged media outlets not to describe Hamas fighters as "militants", comparing the group with the African National Congress (ANC), which sought to end apartheid in South Africa.
The ANC and Nelson Mandela, who served as its president from 1991 to 1997, were "accused of terrorism" by the West but Malaysian authorities had continued to support them, Mr Anwar said.
"There must be awareness in Malaysia, where the media must understand the concerns and sensitivities of the people, as well as recognise the Palestinians' rights over their dispossession of land, wealth, and dignity, which continued to be abused," he said.
More than 10,300 people have been killed in Gaza according to the Hamas-run health ministry, including more than 4,100 children. The Hamas attack on Israel on 7 October killed 1,400 people, mostly civilians, while more than 200 people were taken hostage.