A cotton gin , or a cotton engine is a machine that pulls cotton fibers away from the cotton seeds . The modern cotton gin was invented by the American inventor Eli Whitney . The earliest history of the cotton gin is ambiguous because archeologists likely mistook the cotton gin 's parts for other tools .