In his message, Xi said he was shocked by the terror attack in Barcelona.
On behalf of the Chinese government, the people and in his own name, Xi mourned for the dead and expressed heartfelt sympathies to the bereaved families of the victims.
President Xi said China opposes terrorism in all forms and is ready to work with the international community, including Spain, to strengthen anti-terror cooperation so as to jointly safeguard regional and world peace and stability.
Premier Li Keqiang also sent a message of condolence to Spanish Prime Minister Mariano Rajoy on Friday.
Two deadly car rampages in Spain on Thursday, spread panic in the country and triggered a sweeping anti-terror operation on Friday morning.