Australia has raised the prospect of following the example of the US by relocating its embassy in Israel from Tel Aviv to Jerusalem.

Critics have described the policy shift as a desperate grab for domestic political gain to win a crucial by-election for the ruling Liberal Party.

Australian prime minister Scott Morrison said the idea was suggested to him by a former ambassador to Israel, Dave Sharma, who is a candidate for the Liberal Party in a by-election on Saturday in the Sydney electorate of Wentworth, which has a large Jewish population.

At stake is the government’s single-seat majority in the country’s House of Representatives and Mr Morrison’s ability to retain power without the need for deals with independent MPs.

Mr Morrison said Australia remains committed to finding a two-state solution to Israel’s conflict with the Palestinians.

He said: “When sensible suggestions are put forward that are consistent with your policy positioning and in this case pursuing a two-state solution, Australia should be open-minded to this and I am open-minded to this and our government is open-minded to this.”

Israeli prime minister Benjamin Netanyahu said he had recently spoken to Mr Morrison and welcomed the Australian policy shift.

Mr Morrison “informed me that he is considering officially recognising Jerusalem as the capital of Israel & moving the Australian embassy to Jerusalem. I’m very thankful to him for this,” Mr Netanyahu tweeted.

He added that Israel will “continue to strengthen ties” with Australia.

The Australian Broadcasting Corp reported that an Indonesian official had said Jakarta had been taken by surprise by the announcement, which could harm bilateral trade negotiations.

When Mr Morrison became prime minister in August, he made his first overseas trip to Indonesia, a near-neighbour that is the world’s largest Muslim-majority nation.

Mr Morrison and Indonesian president Joko “Jokowi” Widodo planned to sign an agreement this year aimed at boosting trade and investment.

The Australian leader told parliament that he had briefed Mr Jokowi overnight about the announcement.

“I’ve been pleased to be able to explain very clearly the nature of the announcements that I’ve made today and I’ve been very pleased with the response that I’ve received from President Joko Widodo,” Mr Morrison said.

“We’ll continue to work closely and cooperatively with our allies and with our partners all around the world on these issues.”

The opposition centre-left Labour Party said the announcement was a desperate attempt to win the by-election in the Wentworth electorate.

MP Penny Wong said: “The people of Wentworth, and all Australians, deserve a leader who puts the national interest ahead of his self-interest, and governs in the best long-term interest of the nation.”