BEIJING — Missionaries. Corporate investigators. Billionaires. Legal activists.

China has a long history of arresting or holding foreigners for mysterious reasons, often in a tit-for-tat play to put pressure on overseas rivals. In recent years the number of such detentions has increased, a disturbing trend for foreigners visiting or conducting business in the country.

The Chinese government has detained two prominent foreigners in recent days: Michael Kovrig, a former Canadian diplomat, and Michael Spavor, a Canadian writer and entrepreneur. They are the latest foreigners to be held by the authorities, in what some experts said might be retribution for the arrest of a senior Chinese tech executive in Canada this month.

Here are some recent cases of foreigners caught in the crosshairs of China’s opaque legal system.

Kevin and Julia Garratt, Christian aid workers from Canada, were best known in Dandong, a Chinese city near the border with North Korea, for operating a popular coffee shop. They also worked with a charity that provided food to North Koreans. But in 2014, they were arrested by the Chinese authorities on “suspicion of stealing and spying to obtain state secrets.”

Ms. Garratt was released on bail and allowed to leave China. Mr. Garratt spent two years in prison before his eventual release. Both have denied the accusations.