The country remains deeply conservative, and many disapprove of the holiday as an indecent Western import.
The Islamabad high court issued the order after a petitioner declared love was being used as a "cover" to spread "immorality, nudity and indecency... which is against our rich traditions and values".
The ruling, seen by AFP and greeted with approval by Islamist parties, also called for the electronic and print media to stop promoting Valentine's Day.
Some restaurants in Islamabad continued to send out text messages advertising Valentine's Day promotions even after the ban was announced.
However preparations appeared muted in more conservative areas such as Peshawar, capital of northwestern Khyber-Pakhtunkhwa province, where only a handful of shops were selling Valentine's Day-themed goods.
The annual occasion is increasingly popular among young Pakistanis, many of whom seize the chance to celebrate romance by giving cards, chocolates and gifts to their sweethearts.
But the country remains deeply conservative, and many disapprove of the holiday as an indecent Western import.
Last year, Pakistan president Mamnoon Hussain had urged the nation to refrain from celebrating Valentine's Day, saying it had no place in the Muslim-majority nation. Other officials blasted it as "vulgar and indecent".