QUITO, Ecuador—When Rafael Correa entered Ecuador’s presidency in 2007, the nation faced an opportunity and a challenge. Ecuador’s economy depended on oil, and global crude prices were near a record high. Much of the oil was extracted by foreign companies, however, so as prices surged more wealth began flowing overseas.