General election 2017: Corbyn says task is to keep Britain safe
Jeremy Corbyn has said he will appoint a minister for peace if he wins power, but insisted he was "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.
Labour backed "no first use" nuclear weapons, but he would do "everything necessary" to protect the country.
Foreign Secretary Boris Johnson said Labour would "chuck away" the UK's ability to defend itself.
And Prime Minister Theresa May, campaigning in North Shields, has also been asked about defence policy, if her party wins power on 8 June.
Mrs May was asked by the BBC's Laura Kuenssberg if she thought it patriotic to join the US in more strikes against Syria, or if she would rule out having a parliamentary vote.
Mrs May said the UK was part of a coalition working to "defeat Daesh" in Syria and Iraq but was also working "diplomatically with others to ensure that we can see a stable Syria for the future and a political transition for Syria away from Assad".
In a speech to the Chatham House international affairs think tank on Friday, Mr Corbyn - a former chairman of the Stop the War Coalition and a lifelong member of the Campaign for Nuclear Disarmament - said he had campaigned for a more peaceful world all his life and still believed the UK's interests were best served by pursuing political and diplomatic ends to conflicts.
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 that the use of force should be sanctioned beforehand by the United Nations.
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 Washington but would always speak his mind.
"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 and what he described as the "military-industrial complex" had been shaped by his parents' fears of a "nuclear holocaust" during the 1960s and his memories of the use of chemical weapons during the Vietnam War.
He said he accepted Labour was supporting Trident in its manifesto, draft details of which were leaked on Wednesday, after voting for the policy at its party conference and the Parliament had already backed the renewal of the nuclear weapons system.
But he said an incoming Labour government would have a wide-ranging defence review "looking at all aspects of our defence priorities for the future".
"We cannot obviously decide what the review would decide, otherwise we wouldn't have a review," he said.
He insisted he remained committed to "meaningful, multilateral disarmament" in line with the nuclear non-proliferation treaty.
His deputy leader Tom Watson, campaigning in Pontypridd, said the manifesto, the final version of which has not yet been published, "will have a commitment to the independent nuclear deterrent, to Trident".
But SNP leader Nicola Sturgeon said Mr Corbyn "should have the courage of his convictions on nuclear weapons". She added: ""I want to see Trident scrapped not renewed, so we can have investment in our conventional forces."
The Conservatives said Mr Corbyn had campaigned all his life "to weaken the UK's defences".
Campaigning in Newport, Foreign Secretary Mr Johnson said the Labour leader's criticism of Mr Trump reflected a strain of "immature anti-Americanism" within the opposition.
"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," he said.
But UKIP leader Paul Nuttall said he agreed with Mr Corbyn, arguing the interventions in Iraq and Syria had been mistaken and British troops should only be deployed if it was truly in the national interest.