ISTANBUL—Turkey's top court on Thursday ruled that a ban on YouTube is unconstitutional, paving the way to lift the two-month blockade, after the government cut off access to Google Inc.'s video-sharing website for publishing leaked state secrets just days before critical March elections.

The Constitutional Court in Ankara sided 14-to-2 with individual appeals filed by Google's local attorney, opposition lawmakers and the Union of Turkish Bar Associations, ruling that YouTube's blockade breached freedom of expression, according...