Neostigmine works by inhibiting the enzyme acetylcholinesterase, which breaks down acetylcholine, a neurotransmitter. This inhibition leads to an increase in acetylcholine levels at neuromuscular junctions, enhancing communication between nerves and muscles.