ISTANBUL—President Abdullah Gul late Tuesday signed into law a bill giving the government sweeping powers to block websites and monitor user activity, a move critics assailed as further endangering Turkey's democracy ahead of elections that could reshape the political landscape.

Mr. Gul announced the move on his Twitter account, stressing he had agreed to sign only after government officials pledged to amend two disputed articles of the legislation.

...