China's yuan has been on a tear all year and has now recouped last year's losses — and analysts say there's still room to run.

At its strongest level on Tuesday, the yuan was changing hands at 6.5151 against the U.S. dollar, pushing gains to more than 6 percent this year, according to Reuters data. The currency's appreciation had quickened its pace in August, marking its best month in 2017.

The yuan has strengthened much faster than expected, and it's even bucked the trend. While other Asian currencies have been falling in the face of rising political tensions between the U.S. and North Korea, the Chinese yuan has actually continued appreciating. Experts say the central bank has succeeded in demonstrating it can withstand downward pressure on the currency by tightening capital controls and with foreign exchange intervention.

There's even some talk that the yuan is becoming something of a safe-haven play.

The government's capacity for control "positions the Chinese yuan and China as a source of stability amid uncertain political and economic times," wrote Callum Henderson, managing director at risk consultancy Eurasia Group, in a note. And "it avoids any possibility that the U.S. administration could accuse China of weakening its currency ahead of the 19th Party Congress and President Donald Trump's visit to China."

China's 19th Party Congress is set to kick off mid-October, and it's the country's most important political event in five years, culminating with a change in the upper echelons of leadership. For Beijing, maintaining stability in its economy and markets is a major priority ahead of the power shuffle, which is why the government has been working overtime to support the yuan.

The currency has also been buoyed by a weaker U.S. dollar as buying sentiment for the greenback has soured as the U.S. Federal Reserve has continued signaling it's unlikely to change interest rates for the rest of this year.