Tony Blair told the Chilcot inquiry, at the end of six hours of evidence this afternoon, that he had no regrets for Britain's part in the Iraq war and its aftermath.

In a final statement before the hearing ended just after 5pm, he said that his decision as prime minister had been a "huge responsibility", adding: "There is not a single day that passes that I don't think about it."

But he insisted: "If we had left Saddam in power, even knowing what we know now, we would still have had to deal with him ... we have a completely new security environment today.

"I am sorry it was divisive and I tried my level best to bring people back together again. If I am asked whether Iraq is better, I believe in time to come, if it becomes the country its people want to see, we can look back with an immense sense of pride."

Blair was briefly interrupted by heckles from the public gallery, but continued: "I feel responsibility but no regret for removing Saddam Hussein. I think he was a monster. I believe he threatened not just the region but the world, and in the circumstances we faced it was better to deal with his threat and remove him from office. The world is better as a result.

Blair insisted that conditions in Iraq had improved as a result of the occupation and repeatedly blamed Iran and al-Qaida for attempting to destabilise the British and American efforts to restore order.

He told the Chilcot inquiry in a robust defence of his government's policy: "Nobody would want to go back to the days when they had no freedom, no opportunity and no hope. We are in exactly the same position in Afghanistan. You have got to be prepared for the long haul and prepared to stick it through to the end."The former prime minister admitted that it would have been better for the allies not to have dismantled the Iraqi army after the 2003 war and professed himself shocked and angry to learn of the abuses of Iraqi prisoners at the Abu Ghraib detention centre, because it damaged the occupiers' reputation.

In nearly six hours of questioning, Blair acknowledged few mistakes or regrets about his handling of the Iraq war and its aftermath. He said outside forces – specifically al-Qaida and Iran – undermined British and American efforts. Questioned about the number of casualties during the occupation – a rising toll year by year until 2007 – he retorted: "You have to ask who was doing the killing. The coalition forces were not the ones, it was the terrorists."

He said the allies could have handled "indigenous criminality" but: "People did not think that al-Qaida and Iran would play the role they did."

The influence of Iran has been a recurrent theme of the former prime minister's evidence today.

Earlier in the session Blair said that had the advice of Lord Goldsmith, the government's attorney general, been that an invasion would be illegal the preparations for war would have been stopped in their tracks. "If Peter (Goldsmith) had said this would not be justified lawfully, we would have been unable to take action ... a lot turned on that decision. Therefore it was important that it was by the attorney general and done in a way which we were satisfied was right and correct."

Blair denied that the armed services' leadership was under-prepared or denied equipment for the war. "I don't think I refused a request for money or equipment at any time as prime minister," he said. "They regarded themselves as ready and they performed as ready. They did an extraordinary job."

The former prime minister robustly defended his decision to take Britain to war against Saddam Hussein in 2003 because he believed "beyond doubt" that Iraq had weapons of mass destruction.

He insisted that the joint intelligence committee's assessments were consistently strong that Iraq had a WMD programme.

"It was at least reasonable for me at the time, given this evidence of what the JIC was telling me, that this was a threat I should take very seriously," he said.

"All the intelligence we received was to the same effect. There were people perfectly justifiably and sensibly also saying that you cannot sit around and wait ... you have got to take action clearly and definitively.

"I decided that this intelligence justified our [understanding] that Saddam continued to pose a significant WMD threat."

Blair's only concession was that tabloid headlines in the run-up to the war that Iraq had weapons it could deploy in 45 minutes should have been corrected by the government. But he maintained that the figure only later took on a significance that had not been appreciated at the time.

He said he had sought to give the Bush administration the assurance that it would not act alone. The absolute issue was weapons of mass destruction and that a brutal regime could not be allowed to develop them.

He told the inquiry: "It was right for us to be with America since we believed in this too."

Blair argued that he had had differences with Bush: in persuading him that the Middle East peace process was linked to the terrorism process and he acknowledged that Britain had never believed that Saddam's regime was linked to al-Qaida.

But he added that rogue regimes had the capacity to link up with terrorist organisations.

The former prime minister, now a Middle East peace negotiator, pointed repeatedly to Iran as posing a current threat to the region because of its willingness to assist terrorist organisations. He told the inquiry: "When I look at the way Iran links up with terror groups, a large part of the destabilisation in the Middle East comes from Iran."

"There are very strong links between terrorist organisations and states that will sponsor them. There are those states, Iran in particular, which are linked to this extreme and misguided view of Islam."

Earlier, the former prime minister opened his appearance before the Chilcot inquiry in London by stating that the government's assessment of the scale of a terrorist threat changed dramatically after the al-Qaida attacks on the US on 11 September 2001.

Looking trim and tanned, but greyer than when he was in office, Blair told the inquiry that after 9/11 the British and American view changed "dramatically".

"Here's what changed for me: the whole calculus of risk," he said. "The point about this terrorist act was over 3,000 people had been killed, an absolutely horrific event. But if these people, inspired by this religious fanaticism could have killed 30,000, they would have [done].

"Those of us who dealt with terrorism by the IRA [knew] their terrorism was directed towards political purposes, it was within a framework you could understand. That completely changed from that moment – Iran, Libya, North Korea, Iraq ... All of this had to be brought to an end."

Blair told the inquiry that prior to 9/11 the British and American policy of containing Saddam Hussein's regime with "smart" sanctions had been worth trying, although there were holes in the way they were working.

He pointed out that his government's first military action against Iraq had been taken in conjunction with Bill Clinton's administration in 1998.

"I would fairly describe our policy as doing our best, hoping for the best, but with a different calculus of risk assessment," he said. "We thought he was a risk, but we thought it was appropriate to contain it."

The former prime minister avoided demonstrators outside the Queen Elizabeth Centre in Westminster, where the inquiry is being held, by being driven in early through a cordoned-off area at the back of the building.

At the start of the hearing at 9.30am, inquiry chairman Sir John Chilcot warned members of the public attending not to interrupt and distract the session. He also stated that Blair may be called back at a later stage to give more evidence.