TORONTO (Reuters) - An Ontario judge ordered pro-Palestinian protesters to leave their two-month-old encampment at Canada's largest university by Wednesday evening, granting the University of Toronto's injunction request in a ruling Tuesday.

Police were ordered to arrest and remove anyone contravening the order.

The university had sought an injunction that would have police clear the encampment, which has occupied a grassy part of campus for two months.

Lawyers for the university argued protesters took control of university property when they set up the encampment and are preventing others from using it, as well as harming the school's reputation and making some community members feel unwelcome or unsafe.

"The University has suffered and continues to suffer irreparable harm," it wrote in its injunction application.

Lawyers for the protesters argued the injunction sought by the university would effectively prevent the group from engaging in other forms of protest on or near campus. They argued the university is "closer in character to a public park" than private property, and people do not normally need permission to use it.

The encampment, dozens of tents in a fenced-off, poster-adorned grassy area in the centre of the university's downtown Toronto campus, has been in place since early May. 

Its participants had demanded the university disclose its investments, divest from any that "sustain Israeli apartheid, occupation and illegal settlement of Palestine" and end partnerships with some Israeli academic institutions.

Last month a Quebec court granted a partial injunction to the Université du Québec à Montréal obliging protesters to create a buffer zone allowing access to campus buildings. Two attempts to obtain injunctions ending the encampment at Montreal's McGill University were rebuffed. 

The death toll in Gaza continues to mount as a global hunger monitor warns of imminent famine in the besieged enclave.

(Reporting by Anna Mehler Paperny and Saadeq Ahmed; Editing by Stephen Coates)