Jack Straw rejected advice in the run up to war that invading Iraq without UN backing would break international law, the Iraq inquiry heard.
Mr Straw's chief legal adviser at the time, Sir Michael Wood, told the then foreign secretary it would "amount to the crime of aggression".
But Mr Straw told him he was being "dogmatic" and that "international law was pretty vague", Sir Michael said.
Ministers used the attorney general's advice on the war's legality instead.
Lord Goldsmith, who is due to appear before the inquiry on Wednesday, advised the government that force could be used legally without a second UN resolution.
But the Iraq inquiry heard there were serious concerns about the way in which the decision was reached among the Foreign Office's senior legal advisers.
Elizabeth Wilmshurst, who resigned in protest days before the invasion of Iraq, described the process as "lamentable" and lacking in transparency.
She said it was "extraordinary" that Attorney General Lord Goldsmith had only been asked for his opinion about the war just days before British troops went into action.
Sir Michael - chief legal adviser to the Foreign Office between 2001 and 2006 - said he believed the invasion did not have a legal basis as the UN Security Council neither met to agree Iraq was in "material breach" of existing disarmament resolutions nor explicitly approved the use of force.
"I considered that the use of force against Iraq in March 2003 was contrary to international law," he said
Newly declassified letters published by the inquiry show Sir Michael raised his concerns directly with the foreign secretary.
On 24 January 2003, Sir Michael wrote to Mr Straw telling him the "UK cannot lawfully use force in Iraq in ensuring compliance" on the basis of existing UN resolutions, including resolution 1441 which gave Saddam a "final opportunity" to comply in November 2002.
"To use force without Security Council authority would amount to the crime of aggression," he wrote.
In his reply, also published by the inquiry on Tuesday, Mr Straw said he "noted" Sir Michael's advice but did "not accept it".
Assessing what would constitute a legal basis for war, he said: "I am as committed as anyone to international law and its obligations but it is an uncertain field. In this case, the issue is an arguable one, capable of honestly and reasonably held differences of view."
Mr Straw said he hoped to secure a further UN resolution "for political reasons" but there was a "strong case" that existing resolutions and subsequent Iraqi non-compliance "provide a sufficient basis in international law to justify military action".
Asked about Mr Straw's reaction to his letter voicing concerns, Sir Michael said the foreign secretary had told him he was being "dogmatic and international law was pretty vague".
He said Mr Straw also told him at their meeting that he had "often been advised things were unlawful and gone ahead anyway and won in the courts" when he was home secretary.
Asked by the inquiry about Mr Straw's analysis of the legal position regarding the invasion of Iraq, Sir Michael told the inquiry: "Obviously there are some areas of international law that can be quite uncertain. This, however, turned exclusively on the interpretation of a specific text and it is one on which I think that international law was pretty clear."
He told the inquiry his advice had never been rejected by a minister before or since.
Mr Straw told the inquiry last week that his decision to back the war was the "most difficult" of his career, describing it as a "profoundly difficult political and moral dilemma".
The Lib Dems said Tony Blair and Gordon Brown must be asked whether they were aware of the advice on the war's legality when they appear before the inquiry.
"Michael Wood's statement is the final nail in the coffin of the case for a legal war," said the party's foreign affairs spokesman Ed Davey.
"We need to know just who saw this advice. Did it reach Tony Blair and Gordon Brown? And if not, why not?"
But Sir Michael said he had always made it clear that it was ultimately up to Lord Goldsmith to advise ministers on whether war was lawful.
Just before the conflict began, Lord Goldsmith said in a statement that authority to use force came from the combined effect of existing UN resolutions dating back to the ceasefire after the Gulf War.
Yet 10 days earlier he had told the prime minister "the safest legal course" would be the adoption of a new UN resolution.
Sir Michael said there was a reluctance among ministers to seek legal advice early on as the Iraq crisis escalated and that Lord Goldsmith's ultimate conclusion "came in very late in the day as I see it".
"It was unfortunate advice was not given at an earlier stage."
But former Foreign Secretary Margaret Beckett defended Lord Goldsmith's role, telling the inquiry she believed he had properly weighed up all the legal arguments before coming to a final decision.
"I can't image any pressure he could be subject to that could make him give advice that was anything other than what he thought," she said.