Pemetrexed works in cancer by blocking certain enzymes involved in folate metabolism and DNA synthesis, which interferes with the process needed for a cell to divide and replicate.