A Brazilian military officer who was set to accompany President Jair Bolsonaro on his return trip from the G20 in Tokyo was arrested in Spain after 39kg of cocaine was recovered from his luggage, police have revealed.

The officer was arrested during a stopover Seville on Tuesday. The substance was found in three pieces of luggage, which authorities checked while the plane waited to continue its journey to Tokyo. Bolsonaro was on a different plane at the time.

Vice President Hamilton Mourao told journalists in Brasilia on Tuesday that the man had been assigned to remain in Spain, with orders to embark the president's plane for the final leg of the return trip from Japan.

"Obviously, given the quantities of the drug he was carrying, he didn't buy it on the corner and bring it, right? He was working as a mule. A well-qualified mule, so to speak," he added.

Bolsonaro said in a tweet that he had been informed of the arrest by the defence minister and had ordered "immediate cooperation with Spanish police."

A statement by the Ministry of Defense said: "We are investigating the facts and launching a military police enquiry."