By Gulsen Solaker
ANKARA (Reuters) - Turkey's ruling AK Party on Tuesday faces the first test of its unity since Prime Minister Ahmet Davutoglu announced he was stepping down, as parliament prepares to vote on a divisive bill to lift lawmakers' immunity from prosecution.
Brawls broke out in previous debates over the bill this month between members of the AKP and the pro-Kurdish HDP opposition, which says the legislation is designed to target them and to suppress dissent.
President Tayyip Erdogan, who founded the AKP, has called for members of the HDP to face prosecution, accusing them of links to the outlawed Kurdistan Workers Party (PKK) militant group which has waged a three-decade insurgency in the largely Kurdish southeast.
The HDP, parliament's third biggest party, denies direct links with the militant group.
The vote comes two weeks after Davutoglu said he would leave office at an AKP congress on May 22 following an increasingly public rift with Erdogan, which fueled speculation of splits inside the party. Davutoglu's successor as head of the AKP is widely expected to be a staunch Erdogan ally.
Tuesday's vote on the bill to lift lawmakers' immunity will be a secret ballot as it concerns constitutional change. An anonymous Twitter account seen as close to Erdogan loyalists, which previously predicted Davutoglu's departure, said 71 AKP deputies would oppose the bill.
The bill will need the support of at least 367 deputies in the 550-seat assembly to be passed directly, or it could be taken to a referendum if it wins 330 votes but falls short of the 367.
"God willing we will lift immunities on Friday," said AKP lawmaker Bulent Turan, forecasting the first round of voting would be completed overnight with a second round on Friday. He said his party would go for a national vote if needed.
"If it means a referendum, let there be a referendum. We fear nothing," Turan told reporters.
If approved, the law will remove the immunity of members of parliament who currently face investigation - targeting 138 deputies, of whom 100 are from the HDP and main opposition CHP.
The CHP and nationalist MHP have signaled support for the bill, giving potential support of 489 deputies out of 550 seats in the assembly. However deputies do not vote in line with party orders on constitutional issues and the voting is secret.
Turkish lawmakers currently have immunity from prosecution while they are in office. The police can file "dossiers" against politicians, which can lead to a legal process once they cease to be sitting members of parliament.
(Writing by Daren Butler; Editing by Nick Tattersall and Gareth Jones)