Erdogan withdrew Turkey's membership of the Istanbul Convention on violence against women last year, triggering demonstrations domestically and international condemnation.
Critics had argued that the president did not have the power to unilaterally cancel Turkey's membership of an international agreement.
Tuesday's court decision, which was not immediately detailed to the media, was in a case involving testimony from leading women's rights advocates and legal scholars.
What was the reaction to the court's decision?
The court rejected a petition to annul Erdogan's move in a 40-page ruling that referred to the president's "right of discretion" when interpreting Turkey's laws, according to a lawyer quoted by the AFP news agency.
"It is terrifying from a legal perspective," lawyer Ipek Bozkurt, who was representing the "We Will Stop Femicide Platform" rights group, told AFP. "This erroneous decision should have been stopped by the court."
The group has also called for demonstrations against the court ruling.
Yilmaz Tunc, a member of Erdogan's ruling party, welcomed the court's decision, saying it would put an end to "discussions that lack a legal basis."
Kemal Kilicdaroglu, the leader of the main opposition party, vowed to return Ankara to the treaty "within a week or even 24 hours" should his center-left party come to power in an election next year.
What is the Istanbul Convention?
The 2011 agreement was drafted by the Council of Europe in Istanbul in 2011.
The legal framework, signed by 45 European countries and the EU as an institution, seeks to protect women and promote gender equality through legislation, education and spreading awareness.
According to the treaty, signatories have to adopt legislation to prevent violence against women and strictly punish domestic abuse and gender-based violence.
But women's rights groups had said Turkish authorities were not applying the legal norms of the Istanbul Convention nor providing the intended assistance and protective measures for women.
Conservatives in Turkey say that the treaty was promoting homosexuality, citing its principle of non-discrimination on the grounds of sexual orientation.
Erdogan insisted women in Turkey would not be worse off without the treaty, and in March, the parliament ratified a bill aimed at combating violence against women.
At least 38% of women in Turkey are subject to domestic violence, according to the World Health Organization. The "We Will Stop Femicide" platform has so far reported 226 femicides in Turkey this year.
fb/nm (AFP, AP)