Friday's ruling marks a win for Greens senator Mehreen Faruqi in a Federal Court lawsuit against the One Nation leader.
Justice Angus Stewart found Senator Hanson engaged in "seriously offensive" and intimidating behaviour through the September 2022 social media post that breached the Racial Discrimination Act.
The post was racist, nativist and anti-Muslim, the judge said.
The proceedings involved a post by Senator Hanson on Twitter, now known as X, telling the Greens deputy to "piss off back to Pakistan".
"It is a strong form of racism," Justice Stewart said on Friday.
The post was in response to a one from Senator Faruqi on the day Queen Elizabeth died.
The Greens deputy leader wrote she could not mourn the passing of the leader of a "racist empire built on stolen lives, land and wealth of colonised peoples".
Senator Hanson's claim that she did not know her Greens rival was a Muslim when she sent the tweet was rejected by the court.
Similarly her argument that she merely engaged in political discourse by pointing out hypocrisy from the Greens deputy in criticising the monarchy while benefiting from moving to and living in Australia was also shot down.
"Her tweet was an angry personal attack on Senator Faruqi," Justice Stewart said.
Senator Hanson has been ordered to delete the tweet within seven days and to pay the Greens deputy leader's legal costs of running the lawsuit.
The judge did not make an order proposed by Senator Faruqi that the One Nation leader pay an amount in damages to charity.