The Iraqi police official, speaking on condition of anonymity because he was not authorized to speak to the media, said the bomb went off before dawn, delaying the firefighters' arrival at the scene to extinguish the blaze. Because of the danger across the country, Iraqis avoid going outside before daylight.
Beiji, 155 miles north of Baghdad, is the home to Iraq's largest oil refinery.
The U.S. military said in a statement that the part of the pipeline that was hit was some 7 feet underground and covered with a slab of concrete.
"This act of terrorism is barbaric and demented. This demonstrates al-Qaeda does not care about the Iraqi people or the environment," U.S. military spokesman Lt. Col. Michael Donnelly told The Associated Press.
Donnelly said workers from Iraq's Northern Oil Company were trying to prevent the spill from endangering the river, crops and livestock dependent on river water.
Later the in the day, the spill reached the central city of Tikrit, more than 60 miles to the south, residents and local officials said. Water stations closed in both cities, Tikrit and Beiji.
It was not clear if irrigation officials would allow the spill to reach Baghdad or would block it at Samarra dam, which diverts water into Tharthar lake north of the Iraqi capital.
Insurgents have been attacking the oil industry for years to try deprive the government of money needed for the country's reconstruction.