The US Marine veteran Paul Whelan was formally charged with espionage on Thursday after being detained in Russia last Friday, according to Russian state media.

Russia's Federal Security Service said earlier that he was apprehended while on a "spy mission" but did not provide details other than saying an investigation was underway.

Whelan was granted US consular access on Wednesday, and Jon Huntsman, the US ambassador to Russia, has been in touch with Whelan's family.

Whelan's twin brother, David Whelan, has said Paul Whelan was in Moscow to attend a wedding, and the Whelan family rejects any accusations of espionage or illegal activity.

Whelan could face up to 20 years in prison if he's convicted.

His arrest came about two weeks after Maria Butina, a Russian gun-rights activist accused of acting illegally as a foreign agent, pleaded guilty to engaging in a conspiracy against the US.

Experts say Russia has a history of tit-for-tat moves against the US, particularly when it comes to diplomatic expulsions or espionage.

Paul Whelan, the 48-year-old US Marine veteran and corporate security director who was detained in Russia last Friday, has been formally charged with espionage, the Russian state media agency Interfax reported Thursday.

Russia's Federal Security Service, known as the FSB, has said Whelan was apprehended while on a "spy mission" but has not provided other details.

"The investigation department of the Federal Security Service of Russia initiated a criminal case against a US citizen under article 276 of the Criminal Code of the Russian Federation," the agency said in a statement. "The investigation is underway."

A Russian foreign ministry spokeswoman told reporters on Wednesday that Whelan had been granted consular access.

Whelan's twin brother, David, told CNN on Tuesday that Whelan was in Moscow for a wedding, and his family members reject any accusations of spying.

"We are deeply concerned for his safety and well-being," David Whelan said in a statement to CNN. "His innocence is undoubted, and we trust that his rights will be respected."

Addressing Whelan's detention during a trip to Brazil, Secretary of State Mike Pompeo told reporters: "We've made clear to the Russians our expectation that we will learn more about the charges, come to understand what it is he's been accused of, and if the detention is not appropriate, we will demand his immediate return."

A State Department official told INSIDER that Jon Huntsman, the US ambassador to Russia, visited Whelan at a detention facility in Russia after he was apprehended. A department representative also told Vox that Huntsman had been in touch with Whelan's family.

Whelan flew to Moscow on December 22 to attend the wedding of a fellow Marine veteran to a Russian woman, David Whelan told CNN.

Whelan has been to Russia before, and David Whelan said his brother was with the bride and groom at the Kremlin on Friday acting as a tour guide for wedding guests. But when Whelan didn't show up at the wedding later that day, the couple filed a missing-person report with Russian authorities.

Whelan's family learned of his detention on Monday after media reports surfaced, CNN reported.

"Knowing that he's not dead, it weirdly really helps," David Whelan told CNN. "When we couldn't get a hold of him initially, we were worried, and we are still worried now, but at least we know he is alive."

Read more: US officials seek answers after Russia arrests an American for allegedly spying

Whelan could face up to 20 years in prison if he's convicted of espionage, according to the Russian state news agency TASS.

Russian President Vladimir Putin. Getty Images

Whelan is the director of global security for BorgWarner Inc., an automotive-components supplier based in Michigan. A company representative told The New York Times that he was not in Russia on company business.

Born in Canada to British parents, Whelan served in the Marine Corps Reserve from 1994 to 2008, The Wall Street Journal reported. He was deployed twice to Iraq and but discharged in 2008 for bad conduct after being court-martialed on charges of larceny. He currently resides in Michigan.

According to Quartz, a Marine Corps publication from 2006 featured a photo of Whelan in front of St. Basil's Cathedral in Moscow's Red Square. The caption on the photo said Whelan was spending "two weeks of rest and recuperation leave in Moscow."

CNN reported that Whelan also appeared to have used VKontakte, a Russian social-media platform similar to Facebook, for the past 13 years. The most recent status update on a profile with his name and photos of him says, "next stop, Moscow..." CNN said.

The report said Whelan appeared to have posted several comments in Russian last year. The page also reportedly shows that someone last logged in to the user profile under Whelan's name last Friday, the same day Russian authorities said he was arrested in Moscow.

Maria Butina. Facebook/Maria Butina

Whelan's detention came about two weeks after Maria Butina, a Russian gun-rights activist accused of being a foreign agent, pleaded guilty to engaging in a conspiracy against the United States.

Butina was accused of infiltrating the National Rifle Association and trying to sway US policy in favor of Russia.

Butina was indicted in July on two counts related to conspiracy and acting as an unregistered agent of the Russian government. The indictment said Butina and a high-ranking Russian official, believed to be the Russian politician Alexander Torshin, worked to create a "back channel" between Russia and the US, using the NRA as a conduit.

"Butina sought to establish unofficial lines of communication with Americans having power and influence over US politics," the plea agreement said.

After her arrest in July, the Russian foreign ministry started an aggressive campaign to support Butina.

Russian President Vladimir Putin previously said that he hadn't heard of Butina until her arrest and that she had no ties to the Kremlin or Russian spy agencies. But on December 20, Putin said the charges against Butina had been fabricated and that she was forced to plead guilty to avoid a long prison sentence.

He added, "I don't understand what she could have pleaded guilty to because she was not there to fulfill any government tasks."