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.
Prime Minister Theresa May is appealing directly to “patriotic” Labour voters in the north-west of England on Friday, claiming Mr Corbyn had “deserted” them.
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 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.
“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.
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.
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.
The Conservatives said Mr Corbyn had campaigned all his life “to weaken the UK’s defences”.
Campaigning in Newport, 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.