Iraqi Defence Minister Khaled al-Obeidi's convoy came under sniper fire but he was unharmed, a ministry spokesman said.
Joint operations spokesman Brigadier General Yahya Rasool said the attack took place in the western outskirts of the town of Beiji, 190km north of Baghdad.
"The minister is well and safe," Rasool told Reuters news agency. He said a guard had been lightly injured in the attack.
There was no immediate claim of responsibility for the attack which took place on Monday.
Prime Minister Haider al-Abbadi has said the battle over Beiji and its refinery, Iraq's largest, is critical to the fight against the Islamic State of Iraq and the Levant (ISIL) group.
If Iraqi security forces and Shia militia fighters regain full control of the area around Beiji, it could help them push north towards the ISIL-held city of Mosul and offset losses in the western province of Anbar.
Obeidi was in Beiji as part of a field visit to Salahuddin province. He earlier inspected troops at Camp Speicher, a former US military base, and later toured Tikrit, the home city of former President Saddam Hussein, a ministry statement said.
Beiji has been a battlefront for more than a year, since its seizure by ISIL in June 2014 as they swept through most of northern and western Iraq towards the capital.
ISIL holds about a third of Iraq and neighbouring Syria in its self-declared "caliphate."
A US-led coalition is conducting air strikes to target ISIL across both Syria and Iraq.