Manchester City striker David Silva grabbed the winning goal with six minutes remaining as a well-organised Chinese side proved difficult to break down.
With several Spanish players looking to press claims for a place in Vicente Del Bosque's side for their EURO 2012 opener against Italy next Sunday, it was Santi Cazorla, Fernando Torres and Silva who most caught the eye.
The visitors, coached by former Spain manager Jose Antonio Camacho, looked more dangerous in the opening exchanges and put up a performance that belied their FIFA ranking of 66. Former Celtic player Zheng Zhi caused problems for the Spanish defence on seven minutes when he dispossessed Xabi Alonso in the area and shot wide from a tight angle.
Alvaro Negredo then almost put the hosts ahead after quick thinking from Silva had found him in space, but Zeng Cheng in the Chinese goal did well to block his shot. Iker Casillas was called into action on a number of occasions in the first period as the Chinese caused Spain a number of problems.
The Chinese captain Zhi, who also played in England for Charlton Athletic, was involved in all his side's good work and was only denied the opening goal by the outstreched leg of Casillas after the Chinese side broke at speed on 28 minutes.
Negredo then shot wide after another Silva pass found him with just the keeper to beat, but the Chinese comfortably kept Spain's chances down to a minimum in the first half.
Torres replaced Negredo as Spain's attacking outlet in the second period and another new arrival, Andres Iniesta, produced a spectacular finger tip save from Cheng on 53 minutes. Raul Albiol then hit the post with a header before Iniesta showed great close skill before chipping a shot onto the crossbar.
Torres blazed a volley over the bar and then had two shots charged down in quick succession from the impressive Cheng as the chances started to flow. However Victor Valdes, a second-half replacement for Casillas, had to be alert on 80 minutes to stop a Sun Xiang free-kick that would have given the visitors an unlikely lead.
Six minutes later the breakthrough finally arrived when Iniesta burst into the penalty area before cleverly cutting back for Silva to slide home the winner. Spain will play in Group C at EURO 2012, to be co-hosted by Poland and Ukraine, and will also face the Republic of Ireland and Croatia.