CAIRO — More than a thousand people gathered in downtown Cairo on Friday, chanting slogans denouncing President Abdel Fattah el-Sisi and protesting his decision to transfer sovereignty of two islands in the Red Sea to Saudi Arabia.

The demonstration was the largest in at least two years in Egypt. And it was the most significant public challenge to Mr. Sisi by antigovernment activists who have been all but forced into the shadows by a state crackdown on dissent.

By venturing into the streets in defiance of a strictly enforced ban on political protest — testing the authorities’ often reflexive use of force — the activists appeared emboldened by recent criticism of Mr. Sisi, including from once resolute government loyalists.

The downtown protest and a handful of other demonstrations were in response to Mr. Sisi’s decision last week to transfer sovereignty of Tiran and Sanafir, two uninhabited islands at the mouth of the Gulf of Aqaba in the Red Sea, to Saudi Arabia. The government said it was simply returning to Saudi Arabia territory that had been transferred to Egyptian control in 1950, amid concerns that Israel might seize the islands.