ISTANBUL—Police detained dozens of Prime Minister Recep Tayyip Erdogan's allies in a corruption investigation, sending shock waves through Turkey as a power struggle within the ruling party dramatically intensified three months before crucial elections.

In a series of dawn raids, police took 27 people into custody Tuesday including a municipal leader, the sons of two cabinet ministers and the chief executive of a state bank, the...