The microenvironment of tumors shows high variability in stiffness compared to normal tissues, suggesting that spatiotemporal changes in mechanics play a role in development and progression. Here, we employ microengineered hydrogels with static, dynamic (magnetic field-mediated stiffening and softening), or gradient matrix elasticity to investigate the influence of matrix mechanics in modulating the stem cell-like phenotype in melanoma and breast cancer cells. Using immunofluorescence staining of molecular markers associated with a cancer stem cell (CSC) state, we show that a subtle increase in local stiffness promotes the CSC phenotype, while different mechanical properties in static or dynamic hydrogelswithout gradient profiles of mechanical propertieshave a negligible influence on phenotype switching toward a CSC state. Inhibition of integrins and downstream effectors of mechanotransduction reveals that distinct signaling pathways play a role in regulating the dynamic CSC state in melanoma and breast cancer cells. Our findings demonstrate how cancer cells respond to the local stiffness gradients with dynamic plasticity during progression.