CAIRO — An Egyptian judge on Saturday handed down an unexpectedly harsh verdict in the trial of three journalists from the Al Jazeera English news channel, sentencing them to three years in prison on charges that legal experts said were unfounded and politically motivated.

The verdict was especially stunning because Egyptian officials had repeatedly signaled that they viewed the trial as a nuisance that had brought unwanted scrutiny of the government. The families of the journalists, Mohamed Fahmy, Baher Mohamed and Peter Greste, said they had expected that the men would either be exonerated or sentenced to time already served.

But instead, the judge, Hassan Farid, upheld what human rights advocates said was among many baseless accusations leveled during the journalists’ long legal odyssey: that they had “broadcast false news” about Egypt on Al Jazeera.

The judge also said that the men, who had all previously worked for other international news organizations, were not journalists because they lacked the necessary credentials.