The exhibit, which consists of six hulking, iron boxes containing sculptures depicting scenes from his 81- day incarceration in 2011, will be on show in the nave of cathedral of the central city of Cuenca from July 26th.
The work, entitled S.A.C.R.E.D., show him sleeping on a white cot, being interrogated by officers and watched as he used the bathroom.
The installation was first displayed in 2013 at the Venice Biennale. It will remain on diplay in Cuenca until November 6th.
This is the first time that the Gothic cathedral will host a modern art exhibition, said a spokeswoman for the regional government of Castilla La Mancha which is organising the display.
The exhibit is part of commemorations held across Spain to mark the fourth centenary of the death of its most famous author, Miguel de Cervantes who spent five years in captivity in Algiers and stints in prison.
"There are important parallels between Cervantes and Ai Weiwei," Carmen Olivie, the general director of cultural management firm Eulen Art which is staging the exhibition, told AFP.
"Both suffered captivity, both suffered deprivation of liberty, and that profoundly marked their lives and their vision of art," she added.
China's most prominent contemporary artist, Ai helped design the Bird's Nest stadium for the Beijing Olympics and has been exhibited around the globe, but his works have often fallen foul of China's authorities.
He was detained in 2011 over his advocacy of democracy and human rights as well as other criticisms of the government in Beijing