Special judge PM Tripathi also imposed a penalty of Rs 59,000 each on the convicts--Abdul Wahid Rind alias Murtaza and Fahim alias Sadab Khan, hailing from Karachi.
According to public prosecutor MK Singh, the two were charged for criminal conspiracy, attempting to wage war against the country, collecting fire arms and committing fraud.
Apart from it, they were also charged under the Arms Act and the Foreigners Act.
The Anti-Terrorism Squad (ATS) had arrested the duo on March 26, 2014 from Gorakhpur. The team had recovered two AK-47 rifles, 70 cartridges, two China-made pistols and 45 cartridges from their possession.
The ATS had claimed that the duo had planned to attack the police force.
The Pakistani nationals were produced before the special court on March 27, 2014.