An Iraqi Interior Ministry official said the explosion occurred on Monday at an Iraqi army centre called Tamarat, near the town of Tal Afar, which is close to the restive city of Mosul.
"Forty people have died and 20 were wounded when a suicide bomber blew himself up in the midst of candidates waiting at a recruitment centre for Iraq defence forces," the official said.
The attack was claimed by a coalition led by al-Qaida's Iraq branch. The bomber was a Saudi, the Mujahidin Consultative Council said in a statement on the internet.
The council, established in January, groups seven Sunni Muslim armed factions and is dominated by al-Qaida's Iraqi branch, led by Abu Musab al-Zarqawi.
The bombing on Monday came as tension rose between Shia leaders and US forces over a night-time raid on a Baghdad mosque in which 16 Shia were killed.
President Jalal Talabani ordered an investigation into the raid.
Transit Minister Salam al-Maliki
(L), Jawad al-Maliki in Baghdad
"I decided to set up a joint US-Iraqi committee, which will be led by me, to look into these raids and determine who is responsible for this," Talabani told reporters.
"This is a grave and dangerous incident."
The Shia United Iraqi Alliance (UIA), which holds the largest bloc of seats in the parliament and controls the government, condemned Sunday night's raid, which it said targeted a mosque full of worshippers.
"US forces and Iraqi special forces committed a heinous crime by attacking the Mustafa mosque in the neighbourhood of Ur," said Jawad Maliki, a leader in the prime minister's Dawa party.
"It is a serious crime with grave political and security implications which aims to provoke civil war in the country."
The Shia maintain the raid targeted peaceful worshippers in a mosque, but the US military said the operation was against an insurgent cell and did not involve any mosque.
"Iraqi commandos and soldiers from the Iraqi counter-terrorism force killed 16 insurgents and wounded three others during a house-to-house search on an objective with multiple structures," the US military said in a statement.
The US military acknowledged that members of the US special forces were present in an advisory capacity and said that "no mosques were entered or damaged during this operation".
Iraqis gather at a mosque in
Baghdad a day after a deadly raid
Large numbers of weapons were found, including dozens of assault rifles, rocket-propelled grenades and launchers, two heavy machine guns and material to make explosives.
A dental technician with the Ministry of Health who had been taken hostage the day before was also rescued. He had been tortured for the past 12 hours, the military said.
Also on Monday, 16 employees of a trading company were kidnapped by unidentified gunmen in Baghdad, an interior ministry official said.
"A group of armed gunmen arrived at 10am (0700 GMT) at the premises of Al-Said, an export-import company, and seized 16 of its employees," the official said, adding the incident occurred in Baghdad's Mansour district.
The latest kidnapping is the second biggest abduction within a month targeting company employees.
Ten Iraqis were killed in separate violence across Iraq, seven of them in mortar attacks in south Baghdad that wounded 23 others.