TORONTO, Aug 8 (Reuters) - Saudi Arabia has told hundreds of trainee doctors to leave Canada with only weeks’ notice in the midst of a diplomatic spat, a move that could disrupt Canadian hospitals and end a 40-year-old program to train specialists for the kingdom.

Angered by Ottawa calling for the release of arrested Saudi civil society activists, Saudi Arabia retaliated this week by freezing new trade with Canada, expelling the country’s ambassador and blocking imports of Canadian grain.

Riyadh ordered all Saudi students in Canada to return home by the end of the month, creating a logistical nightmare for the students and for top teaching hospitals in the country.

Saudi Arabia is the largest source of foreign-trained medical residents and fellows, or trainees, in Canada, and was set to occupy 95 percent of international residency spots in the coming academic year.

In 2016, nearly five percent, or 765, of Canada’s trainee doctors came from Saudi medical schools, according to the Association of Faculties of Medicine of Canada.

“We will have to cover any holes in the schedule with either our own trainees or our staff physicians,” said Gillian Howard, a spokeswoman for the University Health Network, which operates four Toronto hospitals that stand to lose 86 doctors.

“It will be stressful, but we have to do it.”

The order to return home affects about 12,000 Saudi students and family members, Saudi officials said on state television.

University of Ottawa law and medicine professor Amir Attaran said a Saudi student he did not know knocked on his door on Tuesday, pleading for help to stay in the country.

“Where do you go with that?” he said. “Of course there’s nothing I can do.”

Saudi students were “worried” and looking for more directives from their government on what to do, said Aseel Ameen of the Saudi Students Club in Ottawa. Some are looking at how to get out of leases on apartments, sell furniture and buy flights. National carrier Saudia, which said it will suspend service to Canada from Monday, set up a hotline for students to call and make arrangements to fly home.

“We hope that everyone will be quick to end all ties and apply for a return ticket to the Kingdom within one month,” the Saudi education ministry tweeted on Tuesday.

The association representing Canada’s resident doctors said in a statement that the Saudi students’ forced departure “could have very negative consequences” on the Canadian healthcare system’s ability to provide timely care.

The Saudi medical trainees are part of a four-decade-old Riyadh-funded program that has trained Saudi graduates to eventually practice medicine at home.

In 2012, a Canadian government release said more Saudi doctors were training in Canada than anywhere else in the world.

The quality of care in Saudi Arabia has been criticized by many Saudis, and the government is under pressure to address a shortage of doctors.

Only 27 percent, or about 24,000, of the country’s doctors and dentists were Saudi nationals in the year 1437 AH, which covers parts of 2015 and 2016, according to Saudi government statistics. The kingdom relies heavily on foreign-born doctors, with specialists in particular commanding high salaries.

“Many of the (Canada-based) trainees are fairly senior, doing fellowships, getting subspecialty experience,” said Salvatore Spadafora, a vice dean with the University of Toronto’s medical school, where 216 students are affected.

“You just know they’re going to go back and do so many great things for their country, and that potential loss is unfortunate.”

The Saudi government has said it will relocate citizens studying in Canada to other countries. But it is not clear when or how medical fellows will resume their specialized training.

Moving countries in the midst of a medical fellowship is “not a common pathway”, Spadafora said.