His resignation will take effect from 1 February.
Mr Kim, 59, was not due to leave until 2022, after he was re-elected for a second five-year term in 2017.
He will "join a firm and focus on increasing infrastructure investments in developing countries", the World Bank said.
In a statement, Mr Kim said: "It has been a great honour to serve as President of this remarkable institution, full of passionate individuals dedicated to the mission of ending extreme poverty in our lifetime".
No reason was given for his unexpected resignation.
Kristalina Georgieva, the World Bank's chief executive officer, will assume the role of interim president.
So he hasn't actually gone yet, but we can still start thinking about who will take over. I am not going to speculate about particular candidates so much as about one big international political sore that will probably flare up again. Will it once again be a United States nominee that gets the job as it always has been?
It goes back to an understanding when the Bank was created in the 1940s, after the Second World War: an American would run the World Bank; a European would be in charge of the International Monetary Fund. That's the way it has always been. It's an arrangement that many regard as anachronistic. The two institutions now have more formalised selection procedures, and the recent preferred European and US candidates have faced challenges. Jim Yong Kim - a Korean American nominated by the Obama Administration - was up against a Colombian and a Nigerian when he was first appointed.
So far, the post-war understanding has prevailed. Will the US under President Trump be open to the idea of ending that arrangement? It would be quite a surprise.
Mr Kim has avoided public clashes with President Trump, but his policy approach was sometimes at odds with the president's approach to climate change.
Under Mr Kim, the World Bank has ended its support of coal power projects - in contrast to Mr Trump's promise to revive the US coal industry.
In April, Mr Kim bowed to pressure from the Trump administration over loan payments to China. The World Bank agreed to change its lending structure in order to secure a $13bn capital increase.
The World Bank has a remit to finance international development projects. Formed in 1947 to help rebuild European countries devastated by World War II, it supports infrastructure projects with traditional loans, interest-free credits, and grants.
He was nominated by former president Barack Obama for both his first and second term at the head of the World Bank.
The World Bank said it would "immediately start the process" of appointing a replacement.
Traditionally, the president of the World Bank has been nominated by the US, while the head of its sister institution, the International Monetary Fund has been picked by European countries. However, when Mr Kim was first appointed in 2012, there was growing pressure from countries in the southern hemisphere for a candidate from an emerging market country to be chosen.
Positioned at 41 in Forbes' Power People 2018 list, Mr Kim has presided over the dispersal of billions of dollars of World Bank funding. In 2018, the multilateral institution made financial commitments worth $67bn.