The bank said in a statement that Flint had resigned from the role "by mutual agreement with the board".
"Although not carrying out his day-to-day duties after today, he remains available to assist HSBC with the transition," the bank added.
Noel Quinn will take over as interim chief executive until a successor is appointed.
The exact amount Flint will get as a payoff remains unknown until he leaves the business, HSBC said. However, he will be entitled to 12 months' salary and a "fixed pay allowance" - of £3.3 million - and "will be eligible to be considered for an annual incentive award".
The bank added: "Mr Flint will not be eligible for an LTI (long-term incentive) award in respect of the 2019 performance year." Last year he was paid £4.6m.
HSBC chairman Mark Tucker said: "On behalf of the board, I would like to thank John for his personal commitment, dedication and the significant contribution that he has made over his long career at the bank.
"Today's positive interim results particularly reflect John's achievements as group chief executive."
Tucker said that although HSBC "is in a strong position to deliver on its strategy", a change of chief executive is necessary.
"In the increasingly complex and challenging global environment in which the bank operates, the board believes a change is needed to meet the challenges that we face and to capture the very significant opportunities before us," he said. He also ruled himself out for the top job.
Flint's departure came as HSBC announced its first-half results for 2019, which showed a rise in pre-tax profit of 15.8 per cent to $12.4 billion (£10.2bn). Its profit after tax was up 18.1 per cent to $9.9bn.
HSBC chief financial officer Ewen Stevenson told investors: "We're not on track with the turnaround of our US business ... The current returns on the US business is not acceptable."
He added: "The US revenues outlook has become more challenged in recent months and we're not expecting a 6 per cent return on targeted tangible equity.
"Trade tensions between the US and China are progressively affecting the growth output in both markets."
The bank also said it intends to initiate a share buy-back of up to $bn, "which we expect to commence shortly".
Flint said it had been a privilege to spend his "entire career with HSBC" and that he was "proud of what we achieved together".
"I have agreed with the board that today's good interim results indicate that this is the right time for change, both for me and the bank.
"After almost 30 years with HSBC, I will be sad to leave but I do so looking forward to a new personal challenge, and confident that our people will continue to serve the bank's stakeholders in the best possible way."
External candidates will be considered in the search for a new chief executive, the company said.
Quinn, who will take up the role in the interim, has been chief executive of global commercial banking, a position he has held since 2015.
The bank added: "He brings a track record of business success, strong client relationships and deep global expertise from his 32 years with HSBC."