SHANGHAI, Oct 21 (Reuters) - The yuan hit a more than 27-month high against the dollar on Wednesday, led by firmer central bank guidance and recent upbeat economic data that showed a sustained recovery in the world's second-largest economy.

Prior to market opening, the People's Bank of China (PBOC) set the midpoint rate at 6.6781 per dollar, 149 pips or 0.22% firmer than the previous fix of 6.6930 and the strongest guidance since July 16, 2018.

Traders and analysts said Wednesday's stronger official fixing largely matched market projections and drove the spot market higher.

The onshore yuan opened at 6.6699 per dollar and jumped to a high of 6.6602, its highest since July 13, 2018. By 0158 GMT, it traded at 6.6683, 87 pips firmer than the previous late session close.

"The yuan continues to strengthen due to its superior economic backdrop relative to other currency trades and sets it at the top of the macro heap," Stephen Innes, chief global markets strategist at Axi, said in a note.

"The better retail sales data for September continues to resonate and signals that domestic demand is holding up."

Official data released this week showed China's economic recovery accelerated in the third quarter as consumers shook off their coronavirus caution.

A trader at a foreign bank said the yuan could march towards 6.6 per dollar level in the near term if authorities do not step in. Several currency traders also noted how far the yuan could rise largely depended on the regulator's attitude on recent rallies.

"Yuan appreciation could have a contractionary effect on the economy, the central bank apparently does not want to see too rapid a rise in the exchange rate," said Xie Yaxuan, chief macro analyst at China Merchants Securities.

"Although the central bank avoids direct participation in the FX market, it can still affect supply and demand of yuan and dollars through market-based methods."

Earlier this month, the PBOC cancelled foreign exchange forward reserve requirements, seen widely as a sign that authorities were uncomfortable with the yuan's fast gains.

The offshore yuan rose to 6.6506 per dollar in early Asian trade, the strongest since July 11, 2018. It was trading at 6.657 by 0158 GMT. (Reporting by Winni Zhou and Andrew Galbraith; Editing by Sam Holmes)