Mr Yildirim said those responsible would pay the "highest price"
An army group in Turkey says it has taken control of the country, with bridges closed in Istanbul and aircraft flying low over Ankara.
PM Binali Yildirim earlier denounced an "illegal action" by a military "group", stressing it was not a coup. He said that the government remained in charge.
Traffic has been stopped from crossing both the Bosphorus and Fatih Sultan Mehmet bridges in Istanbul.
There are reports of gunshots in the capital Ankara.
Gunfire was also heard outside Istanbul police HQ and tanks are said to be stationed outside Istanbul airport. All flights are cancelled.
CNN Turk reported that President Recep Tayyip Erdogan was "safe" but did not elaborate.
A statement from the military group read out on NTV television said: "The power in the country has been seized in its entirety." Who represents the group remains uncertain.
But Mr Yildirim told NTV by telephone: "We are working on the possibility of an attempt. We will not allow this attempt.
"Those who are in this illegal act will pay the highest price," he added, saying it would not be correct to describe the move as a "coup".
He said: "There was an illegal act by a group within the military that was acting out of the chain of military command. Our people should know that we will not allow any activity that would harm democracy."
There are reports Turkey's top general has been taken hostage at the military HQ.