Jeremy Corbyn has said he will appoint a minister for peace if he wins power but insisted he is “not a pacifist”.
Speaking in London, the Labour leader said he would “reshape” relationships with the US and other allies, promising “no hand holding” with Donald Trump.
He said Labour was committed to “no first use” nuclear weapons – but he would do “everything necessary” to protect the country.
The Tories said he would “chuck away” the UK’s ability to defend itself.
Prime Minister Theresa May will appeal directly to “patriotic” Labour voters in the north-west of England on Friday, claiming Mr Corbyn had “deserted” them.
- Election 2017: live updates
- Theresa May to appeal to Labour voters
- Corbyn: Manifesto ‘unanimously agreed’
In a speech to the Chatham House international affairs think tank on Friday, Mr Corbyn – a former chairman of the Stop the War Coalition – said he had campaigned for a more peaceful world all his life and still believed the the UK’s interests were best served by pursuing peace.
But he said should his party win power on 8 June, he would do “everything necessary to protect the safety and security of our people and our country”, stressing “that is our first duty”.
By Jonathan Marcus, defence and diplomatic correspondent
In focusing on the deficiencies of recent western military interventions in the Middle East – what Mr Corbyn called “regime change wars” – the Labour leader put forward a view that might well resonate more widely among the electorate.
His was an approach that would put human rights at the centre of foreign policy.
The problem is that on specifics Mr Corbyn provided little clarity.
He was more critical of the Trump administration than he was of Russia or China.
While stressing Labour’s commitment to current levels of defence spending, he opposed the Nato deployment of troops closer to Russia to reassure worried allies.
He insisted that he was no pacifist and that in the last resort force might sometimes be necessary.
But by stressing the role of the UN Security Council he appeared to give Russia and China a veto over any UK decision to use force.
While condemning the “almost routine” military interventions of the past 15 years, from Afghanistan to Libya, he said he accepted that military action was needed “as a last resort”, citing the fight against Nazism during World War Two.
“I am not a pacifist. I accept that military action, under international law and as a genuine last resort, is in some circumstances necessary. But that is very far from the kind of unilateral wars and interventions that have almost become routine in recent times.”
He said a “bomb first, talk later” approach to security “has failed” and is a “recipe for increasing, not reducing threats and insecurity”.
He criticised the Trump administration for “unilateral” air strikes in Syria and “recklessly escalating” tensions on the Korean peninsula, saying he wanted “strong and friendly relations” with the US but would speak his mind to Washington.
“Waiting to see which way the wind blows in Washington isn’t strong leadership. And pandering to an erratic Trump administration will not deliver stability,” he said. “Britain deserves better than simply outsourcing our country’s security and prosperity to the whims of the Trump White House.
“So no more hand holding with Donald Trump – a Labour government will conduct a robust and independent foreign policy made in London.”
Earlier this year, Mr Corbyn criticised US air strikes against Syria – putting him at odds with Labour deputy leader Tom Watson.
- Lib Dem hopeful says ‘don’t vote for me’
- Poll tracker: Who is in the lead?
- First-time voters in Britain’s oldest recorded town
The Labour leader said his life-long opposition to nuclear weapons had been shaped by his parents’ fears of a “nuclear holocaust” during the Cold War.
While he accepted Labour was supporting Trident in its manifesto, draft details of which were leaked on Wednesday, and Parliament had already backed its renewal, he said an incoming Labour government would have a wide-ranging defence review.
He insisted he remained committed to “meaningful, multilateral disarmament” in line with the nuclear non-proliferation treaty.
Last year, Mr Corbyn said the 2003 invasion of Iraq, which he voted against at the time, was “an act of military aggression” and a “catastrophe”.
Responding to the publication of Sir John Chilcot’s inquiry into the war, Mr Corbyn said MPs had been “misled” in the run-up to the invasion.
He also apologised on behalf of Labour, which was in government at the time, and called for more powers for the International Criminal Court.
Asked what military action Mr Corbyn would countenance as prime minister, shadow international trade secretary Barry Gardiner earlier told the BBC he would act if the UK was “at risk of being attacked by another nation”.
The Conservatives said the Labour leader had campaigned all his life “to weaken the UK’s defences”.
“There is a sharp distinction between a government that is willing to stand up for this country, that is will to make sure this country is properly defended and a Labour party, led by Jeremy Corbyn, that would simply chuck away our ability to defend ourselves,” Foreign Secretary Boris Johnson said.
“I think that is crazy and not the way I want to go.”