Europe's biggest bank revealed last year it was considering whether to move elsewhere over concerns about stricter regulations.
HSBC Group chairman Douglas Flint said the decision to keep the London HQ "offered the best outcome for our customers and shareholders".
The announcement comes after chancellor George Osborne made a series of concessions to the city in recent months.
HSBC chief executive, Stuart Gulliver, said: "Having our headquarters in the UK and our significant business in Asia Pacific delivers the best of both worlds to our stakeholders."
A treasury spokeswoman added: "We welcome HSBC's decision. They've looked carefully and dispassionately at the facts and confirmed that the UK is the best place to base a global business.
"It's a vote of confidence in the government's economic plan, and a boost to our goal of making the UK a great place to do more business with China and the rest of Asia."
The bank's decision was seized upon by campaigners for UK withdrawal from the EU, who said it undermined pro-European claims that Brexit might trigger an exodus of major firms for the continent.
Matthew Elliott, chief executive of the Vote Leave campaign, said: "HSBC claimed that it might move its headquarters due to uncertainty about whether the UK would stay in the EU. This was an attempt to scare people into backing EU membership.
"Today's announcement shows that even the proponents of Project Fear don't actually believe it."
But Flint said that HSBC could still shift employees and work to France in the case of British withdrawal.
He told the BBC Radio 4 Today programme: "We are lucky in the sense that we have a major bank in France. So, if we were to leave and if there were to be restrictions, ultimately, on the renegotiation of Britain's position, we have the ability to move activity and people between London and Paris.
"But our strong economic view is that Britain is better within a reformed Europe."
HBSC said the board's decision to keep its headquarters in London was "unanimous".
In its later stages, the review was "narrowed" to the UK and Hong Kong, "both of which are considered by the board to be world-class financial centres", it added.
In a statement, the bank said: "The UK is an important and globally connected economy. It has an internationally respected regulatory framework and legal system, and immense experience in handling complex international affairs.
"London is one of the world's leading international financial centres and home to a large pool of highly skilled, international talent. It remains therefore ideally positioned to be the home base for a global financial institution such as HSBC."
Mr Flint said maintaining the bank's hub in London was "not only compatible, but offered the best outcome for our customers and shareholders".
HSBC's review was announced in April last year at the bank's annual meeting.
It cited increasingly onerous British regulatory conditions and the UK bank levy introduced in 2010 - a tax based on the size of any British-based banks' global balance sheet.
HSBC, which has 48,000 of its 257,000 staff in the UK, s aid the levy cost it 1.1 billion US dollars (£720 million) in 2014.
During its review, the bank reportedly looked at bases in Hong Kong, Singapore, the US and Frankfurt.
But since then, Osborne said in last July's Budget that he would gradually reduce the bank levy over the coming years.
He has also called for a ''new settlement'' to end banker bashing and was widely reported to have ousted tough-minded Martin Wheatley, head of City watchdog the Financial Conduct Authority (FCA) in July - raising concerns about political influence at the regulator.
The decision to stay in London comes ahead of HSBC's annual results on February 22.
The bank said it will no longer review the location of its headquarters every three years, and will only revisit the matter if there is a "material change in circumstances".
Carolyn Fairbairn, director-general of Confederation of British Industry (CBI), said: "Strong banks which can provide the finance businesses need to grow are critical for the British economy.
"And we want to have truly global companies, major employers like HSBC, headquartered here so this announcement is good news.
"HSBC's thorough review and consideration of other international financial centres emphasises the need for the UK to continuously stay competitive on regulation, tax and talent."
Our BQ Bulletin emails will land in your inbox at 7.30am, Monday to Friday, with a mix of the latest local business news, national news, and features to inspire you. Sign up here!
Click here to read our privacy statement