Despite the higher efficiency, larger color range and faster stimulus response of polymeric electrochromic materials, their poor cyclability strongly hampers their application in optoelectronics. As an original strategy to stabilize and further nanostructure these polymers, herein an efficient encapsulation and in situ polymerization inside highly porous metal-organic frameworks (MOFs) is reported. In particular, the successful accommodation of poly(3,4-ethylendioxythiophene) (PEDOT) and its partially oxidized polarons inside the mesopores of the nontoxic iron trimesate MIL-100(Fe) is convincingly proved by a large panel of experimental techniques. Remarkably, the polymer-MOF interaction occurring for entrapped PEDOT within the pores (deeply assessed by experimental and simulation methods) might be responsible for the enhanced electrical conductivity of the resulting PEDOT@MIL-100(Fe) composite when compared to the insulating MIL-100(Fe) and the conductive free PEDOT. Furthermore, it was possible to observe the electrochromic properties of the PEDOT@MIL-100(Fe) composite, achieving an improved stability and good cyclability as a consequence of the effective protection by the MOF matrix.