Boris Johnson has confirmed that he will defy the wishes of David Cameron by campaigning for Britain to leave the European Union.

There has been mounting speculation in recent weeks that the London mayor would join the Leave side of the referendum, but Johnson refused to declare his allegiance until the prime minister unveiled his deal for reform within the EU.

Johnson gave a live statement outside his London home confirming that he will back an exit from the EU, albeit "with a huge amount of heartache", as he did not want to defy the prime minister but felt he had no choice because he wanted "a better deal" for people in Britain.

"I look at what the prime minster achieved the other day," said Johnson. "Given the time he had he did fantastically well, and I think everyone should pay tribute to David Cameron for what he pulled off in such a short space of time, but I don't think anyone could claim that this is fundamental reform of the EU or of Britain's relationships with the EU.

"It's my view, after 30 years of writing about this, we have a chance actually to do something. I have a chance to do something. I would like to see a new relationship based more on trade, on cooperation, but with much less of this supranational element."

Johnson later detailed his reasons for backing the Leave campaign in his column for The Telegraph, saying: "There is only one way to get the change we need – and that is to vote to go; because all EU history shows that they only really listen to a population when it says no."

Jack Taylor / AFP / Getty Images

Johnson's announcement is a huge boost for the Leave side as the campaign gathers momentum ahead of the 23 June referendum. The London mayor now ranks as one of the most high-profile figures backing an EU exit. alongside cabinet ministers such as Michael Gove, Chris Grayling, and Iain Duncan Smith.

Earlier on Sunday, Cameron warned Johnson against "linking arms with Nigel Farage and George Galloway" on the Leave side ahead of the referendum, saying an EU exit would be "a leap in the dark".

Speaking on The Andrew Marr Show, Cameron said: "If Boris, if others, really care about being able to get things done in our world, then the EU is one of the ways in which we get them done."

Johnson said he did not want to anger the prime minister, and made it clear that he will not take part in TV debates against his Conservative colleagues, but felt he had no choice but to back a Leave vote to "take back control".

"The last thing I wanted was to go against David Cameron or the government, but after a great deal of heartache, I don't think there's anything else I can do," said Johnson.

"I will be advocating Vote Leave, or whatever the team is called – I understand there are many of them. It is because I want a better deal for the people of this country. To save them money and to take back control."

Johnson's announcement was celebrated as a huge boost to the Vote Leave campaign, which printed out "Boris backs Britain" posters.

Prominent Eurosceptic Douglas Carswell, UKIP's only MP, called the announcement a "game changer".

But Will Straw, the executive director for Remain campaign Britain Stronger in Europe, said Johnson has "serious questions to answer" over his position.

"Boris has finally made his mind up after months of – in his own words – veering around like a shopping trolley on the biggest choice of our generation. Now he's finally come clean, he has some serious questions to answer," said Straw.

"Does he still think Britain's membership of the single market benefits businesses and shoppers or has he changed his mind on this too? He says he wants more trade, but leaving would make trade harder, push up prices for consumers, and weaken economic and national security.

"Boris might be a big personality but he highlights the Out campaigns' biggest weakness – they have no consistency or clarity on what leaving Europe means for Britain and how our economy can be protected from the outside."

Jamie Ross is a Scotland reporter for BuzzFeed News and is based in Edinburgh.