The announcement came Monday, and Taiwan's government said the exchange took place as a goodwill gesture, Deutsche Welle reported.
The two sides exchanged agents at a 2-to-1 ratio. Beijing released Taiwan's Chu Kung-hsun and Hsu Chang-kuo, detained in China for nine years, and Taiwan freed Li Zhihao, placed in prison 16 years ago, the BBC reported.
Li was serving a life sentence.
The news follows the steady easing of tensions since Ma assumed office in 2008. The Taiwanese leader vowed to improve ties and on Nov. 7 held a historic summit with Xi.
Taiwan has grown economically closer to the mainland, but the political maneuvers of Ma's ruling party, the Kuomintang, have led to its waning popularity among voters. Ma's critics have said the outgoing president wants to burnish his legacy and send a subtle message to the opposition.
China still considers Taiwan a renegade province, and Beijing has at times threatened to deploy military forces to retake the island.
But the exchange of prisoners could mean a break from the old cycle of antagonism.
"This is based on a mutual goodwill gesture delivered by the Ma-Xi meeting...President Ma hopes cross-strait mutual exchanges can continue and make more concrete achievements in the future," presidential spokesman Charles Chen said Monday.
Though the swap is unprecedented, according to Taiwan media, the BBC reported some Taiwanese civilians convicted of spying remained imprisoned.
Many Taiwanese remain wary of China's growing influence.