Tony Blair has held talks with Iraqi leaders in Baghdad during the UK prime minister's first trip to the city.
The visit comes as a wave of violence shakes Iraq
He was briefed on preparations for the national poll, which is scheduled for next month but is threatened by a deadly campaign of insurgent violence.
"There is only one side to be on in what is very clearly a battle between democracy and terror," Mr Blair said.
He flew to Baghdad's Green Zone administrative centre in a convoy of helicopter gunships from the airport.
Mr Blair wore a dark civilian suit for the trip. He wore no flak jacket, unlike the military officials and journalists who accompanied him.
After talks in the Green Zone with Mr Allawi, he met UK and US officials, and members of Iraq's Electoral Commission whom he praised for risking their lives "to make sure the people of Iraq get a chance to decide their own destiny".
"I said to them that I thought they were the heroes of the new Iraq," he said.
Mr Blair has invested great political capital on a successful political process to lead Iraq out of the current violent crisis.
He told a news conference that he hoped all Iraqis would take part in next month's elections "on an inclusive basis".
"The danger people feel here is coming from the terrorists and insurgents who are trying to stop the country from becoming a democracy," he said.
Mr Allawi, for his part, said the interim government was committed to holding the elections as scheduled, despite calls for a delay because of the violence.
"We now are on the verge, for the first time in history, of having democracy in action in this country," the Iraqi leader added.
Mr Allawi has accused insurgents, who bombed Shia Muslim targets on Sunday killing nearly 70 people, of trying to bring about ethnic and religious conflicts in Iraq.
"Our enemies are determined to break our will...," he said. "We will not allow them to prevail."
Threat of violence
In the latest violence the US launched an air strike on the town of Hit, in a Sunni Muslim region west of Baghdad, killing six people and wounding 10, according to hospital officials.
Until his arrival at the Green Zone - which is a frequent target for insurgents - Mr Blair's visit had been subject to a news blackout for security reasons.
He later flew to Basra in southern Iraq where British forces are stationed.
He is the first British prime minister to see Baghdad since Winston Churchill.
President George W Bush did not leave the US military base at Baghdad airport during his Thanksgiving stopover in November 2003 and news of the visit was not published until he had flown out.
Mr Blair's visit comes a day after Mr Bush admitted the campaign of violence was affecting US plans for Iraq.
Later in his Middle East tour, Mr Blair is expected to hold meetings with both sides in the Israeli-Palestinian conflict.