Chief Justice Iqbal Hameed-ur-Rehman of the Islamabad high court dismissed the petition filed by Inamur Rehman, a retired army officer.
The chief justice said during the hearing that according to the Army Service Act, matters related to the military cannot be taken up by the high court.
The chief justice then dismissed the petition, saying it was non-maintainable.
The petitioner said the ex-servicemen's society, which represented hundreds of thousands of retired military personnel, had been expressing serious concern at the extensions given to some officers as it would adversely affect the chain of command.
Kayani was given an unprecedented three-year extension by the government in July 2010.
He is now set to retire next year though he attained the age of superannuation (60 years) on April 20 this year.
No permanent role for women in combat areas: Govt
US special envoy meets Pak FM, discusses Afghanistan
India to focus on terrorism, global economy, UNSC reforms
Nearly 200 arrested in Pak for violent protests
7 terrorists killed in US drone strike in Pakistan