ISTANBUL—The Turkish government blocked YouTube and restricted local media, drawing international outrage days ahead of critical local elections seen as a referendum on Prime Minister Recep Tayyip Erdogan's rule.

The move on Thursday, which comes a week after Mr. Erdogan's government shut access to Twitter, was condemned by policy makers in Washington and Brussels. The ban, which blocked Turkish media from broadcasting the content of an audio leak, consolidated Turkey's place in a small club of nations with draconian Internet...