He had the support of the Holy Roman Emperor in exchange for his support in the War of the Spanish Succession, which meant he had a powerful ally to back his claim. Yet not all would acknowledge it right away, and because the Duchy of Prussia was not as being as the large Prussian Region, Frederick I and Frederick William I styled themselves as Kings in Prussia, rather than Kings of Prussia. (In effect proclaiming the Duchy of Prussia to be a kingdom, but avoiding naming it the Kingdom of Prussia.)
Formally, in one of the Treaties of Utrecht (the collection of which ended the War of the Spanish Succession), France acknowledged Frederick I as King in Prussia, and from there on it was essentially an established fact that he was King in Prussia.
This matches the general principle of the matter. Being treated as a king by foreign sovereigns was a matter of acknowledgment and tradition. For example, while the Russians intended for their Tsar to be considered equal to an Emperor in tank, and Peter I of Russia issued an edict to that effect, many other European powers refused to acknowledge the title as being more than the equivalent of a King, and over time this stuck, and the Russians Tsars started to incorporate titles like Tsar of Poland into their full style, thus effectively acknowledging the title Tsar to be equivalent to a king, or at least potentially so.