The Islamabad High Court ruled that citizens who disguised their religious affiliation were guilty of betraying the state and ordered that anyone applying for government jobs should declare their faith.
"The Government of Pakistan shall take special measure ensuring availability of correct particulars of all the citizens," Justice Shaukat Aziz Siddiqui said in the judgment.
"It should not be possible for any citizen to hide his/her real identity and recognition."
If no appeal is launched, the court's directives will have to be followed.
The vast majority of Pakistan's 208 million people are Muslims, with minorities accounting for about 3 percent of the population, according to a 1998 census.
The Ahmadi community has been a target of mob violence and attacks since legislation categorized the sect as non-Muslim in 1974 and have been vilified as blasphemers by leaders of new ultra-religious political party Tehreek-e-Labaik Pakistan.
The judge "is not only attacking everybody's religious freedom in Pakistan but he is also focusing on one particular sect, which is the Ahmadis," said Human Rights Watch representative Saroop Ijaz.
"A judgment like this would enable and incite violence."
The order was issued as a result of a petition brought forward by Tehreek-e-Labaik in connection with a change in wording to an electoral law. The amendment sought to replace a religious oath with a simple declaration, which Tehreek-e-Labaik said was blasphemy.
The government blamed the change on a clerical error and swiftly restored the original format.
Last year, Tehreek-e-Labaik shut down the nation's capital for nearly three weeks with protests against the change.
Seven people were killed and nearly 200 wounded in a failed police bid to disperse protesters, leading the government to give way to their demand that a minister accused of blasphemy resign.
Insulting the Prophet Mohammad is punishable by death in Pakistan and even a rumor of blasphemy can spark mob violence.
"All his (the judge's) specific instructions are about ensuring and finding out who is an Ahmadi," human rights lawyer Jibran Nasir told Reuters, adding that the order would automatically provide the government with specific lists about who belongs to which minority group.
"Every day they are being institutionally reminded that they are a minority," he added. "It is a bigoted order."
Pakistan's minority Shi'ite Muslims regularly come under attack by Islamist groups. Members of its small Hindu and Christian communities have also sometimes been accused of blasphemy.