Pyridostigmine works by inhibiting the enzyme acetylcholinesterase, which breaks down the neurotransmitter acetylcholine. By inhibiting this enzyme, pyridostigmine increases the levels of acetylcholine at the neuromuscular junction, which helps improve muscle strength and function in individuals with myasthenia gravis.