The militants, who were armed with assault rifles and wearing suicide vests, tried to enter the Bacha Khan International Airport but the attempt was foiled by Pakistani security forces.
Three of the rockets landed inside the airport but did not cause any major damage while two more hit nearby residential areas at around 8.30 pm.
The attackers also rammed an explosives-laden vehicle into the wall of the airport, which is used by civilian flights and the Pakistan Air Force.
Troops posted in the area retaliated and footage beamed by TV news channels featured the sound of an intense exchange of fire.
Officials of Khyber Teaching Hospital said they had received the bodies of four civilians and more than 40 have been injured.
Defence Minister Naveed Qamar said the attack was well planned out and terrorists were heavily-armed, however the resonse by the security forces ensured there had been no damage to property or loss of life within the airport.
Senior official Umar Ayub described the condition of four of the wounded as serious.
Children, women and senior citizens were among the injured, who were hit by bullets and shrapnel from rockets.
Security officials said five terrorists were killed in the gun battle with troops. Bomb disposal experts defused four suicide jackets.
"Security forces were fully alert and responded to the attack... There is no damage to equipment and personnel," a Pakistan Air Force spokesman said in a statement.
The banned Tehrik-e-Taliban Pakistan claimed responsibility for the attack.
A spokesman for the group told reporters in the country's northwest that the target of the attackers was the PAF airbase.
The terrorist attack on the airport was launched from a nearby village named Abdra, the PAF spokesman said.
A joint operation by security agencies was "in progress to clear the area", he said.
The rockets fired by the attackers damaged the airport's outer wall at a few places but "no terrorist has been able to penetrate inside", the spokesman further said.
Officials of the Civil Aviation Authority said the airport was shut down after the attack began and all flights coming to Peshawar were diverted to Islamabad and Lahore.
They said all persons and civilian aircraft inside the airport were safe.
Additional security forces were deployed around the airport and troops searched houses in nearby neighbourhoods.