"It should not be forgotten that the Turkish armed forces is one of the sides in this debate and the absolute defender of secularism," the statement said.
"When necessary, they will display their attitudes and actions very clearly. No one should doubt that."
The military said the the "Islamist" agenda of the ruling party threatened the very foundation of the Turkish state.
"This radical Islamic understanding, which is against the Republic and has no goal but to erode the basic qualities of the state, has been expanding its span with encouragement," the military statement said.
|Opposition parties boycotted Friday's vote to select a new president [Reuters]|
Gul, the foreign minister, failed to win enough votes in a first round of voting in parliament on Friday after mainly-secularist opposition parties boycotted the first of four votes which will culminate in the selection of a new president.
The boycott was aimed at preventing the Justice and Development Party of obtaining the 367 votes of the 550-seat Parliament needed for the vote to be valid.
Ruling party legislators went ahead with the balloting, and Gul received 357 votes.
At least 367 votes are required to win in the first two rounds, but only a simple majority, or 276 votes, is needed for victory in the third due to be held on May 9.
The ruling party says only one-third is needed for a quorum, and it expected that Gul, would prevail by the end of the voting process next month.
The second round is scheduled for May 2. Gul, whose party holds 353 seats, is likely to win in the third round.
He has promised to uphold the country's secular traditions amid concerns that his victory will strengthen the role of Islam in politics.