The plane crashed in a built-up area in Rawalpindi. (AFP)

Pakistani military aircraft on a training flight crashed in a built-up area in the garrison city of Rawalpindi early on Tuesday, killing all five crew members and 12 civilians, an army statement said.

Another 12 civilians were injured in the crash, which set off a fire. Rawalpindi is close to the capital, Islamabad, and is where the headquarters of the Pakistan army is based.

The website of newspaper The News carried footage showing a building engulfed in flames. There was no immediate word on the cause of the crash or the type of aircraft involved.

Military and civilian rescue teams were at the scene and extinguished the fire and took the injured to hospital, the statement from the army's communications wing said.