Speaking in the National Assembly or lower house of Parliament after the resolution was passed by a two-thirds majority in the 342-member House, Gilani said his government may have differences of opinion with the judiciary and military but both institutions must play their role in defending democracy.
As members of the treasury benches thumped their desks, Gilani said the military and judiciary cannot "pack up the system" or derail it.
His remarks came against the backdrop of the government's confrontation with the military and the judiciary over the memo scandal and the reopening of high-profile graft cases.
The parliament convened to vote on the pro-democracy resolution that was introduced by a junior partner of the ruling Pakistan People's Party (PPP) hours after the Supreme Court issued a notice for contempt of court to Gilani for failing to revive graft cases against President Asif Ali Zardari.
Gilani told the House that he would appear before the court on January 19 as he respected the judiciary. "We have always respected the courts. The court has called me and in respect to the court, I will go on January 19 and appear before (the judges)," he announced.
A defiant Gilani said the ruling coalition had not approached parliament with the pro-democracy resolution because it felt the government was facing a threat.
"We did not come (to parliament) under threat, we did not come to get a vote of confidence, we have not come against any institution nor are we against any institution," he said.
Pakistan's apex court has been pressuring the government to reopen graft cases against Zardari and 8,000 other people since it struck down the National Reconciliation Ordinance, a graft amnesty issued by former military ruler Pervez Musharraf, in December 2009.
The government has refused to act against Zardari, saying he enjoys immunity from prosecution under the Constitution.
During his speech, Gilani took a swipe at his government's detractors for not seeking any action against the "architect" of the NRO.
Without naming Musharraf, he said, "Who made the NRO? We didn't make this mistake. Those who made the NRO are outside (the country) and everyone else inside is being held accountable."
"Who are the architects of NRO? This House wants to know if we are being punished for it while the architect of the NRO is saying Pakistan is remembering and making plans to come back," he said, in a reference to Musharraf's plans to return from self-exile later this month.
The government had convened the special session of Parliament to take up the pro-democracy resolution and send out a message that democracy in Pakistan was stable, Gilani said.
"We wanted to send a message to the world that here is a responsible parliament, which is sovereign and supreme," he added.
Earlier in the day, the PPP's coalition partners reposed full confidence in Gilani and decided that he would appear in the Supreme Court to face the contempt notice.
Image: Pakistan Prime Minister Yousuf Raza Gilani
Gilani says no to retracting statement against military
MORE TROUBLE: Now Pak SC pulls up Gilani for contempt
Turmoil in Islamabad: Where will the buck stop?
Rs 1.1 crore bounty on Pervez Musharraf's head
Rahul's 'Mission 85' to focus on reserved seats