Senior police official Rao Mohammad Iqbal said the motorcade was on its way to the airport to pick up the premier at the time of the attack.
"The car was going towards the airport when it was fired upon from a small hill ... two bullets hit the driver's window," Iqbal said, according to Reuters.
Pakistani Taliban spokesman Muslim Khan claimed responsibility, saying Gilani was responsible for offensives against militants in the northwest.
"We will continue such attacks on government officials and installations," Khan said, Reuters reported.
Gilani is a senior member of former prime minister Benazir Bhutto's Peoples Pakistan Party. She was killed while campaigning Dec. 27 in a suicide gun and bomb attack.
The Pakistani government said al-Qaida-linked militants perpetrated the attack.
Wednesday's incident raised tensions in Pakistan, where a new civilian government is vowing to crack down on Islamic militants after forcing President Pervez Musharraf to resign. He also escaped two bomb attacks, which also were attributed to al-Qaida.
Elections to replace Musharraf have been scheduled for Saturday.
Meanwhile, Pakistani officials said a raid along the Afghanistan-Pakistan border involving U.S.-led or NATO forces killed several civilians.
A statement from the Foreign Ministry described the raid in the South Waziristan region as a ground attack supported by air assets based in Afghanistan, reported the Associated Press.
South Waziristan is considered a militant stronghold, and the United States has pressed Pakistan to crack down on insurgents who use it as a base for attacks inside Afghanistan.