When alkyl iodide is treated with excess ammonia, it leads to the formation of a primary amine. The reaction proceeds via nucleophilic substitution, where ammonia (NH$_3$) replaces the iodine atom of the alkyl iodide. In excess ammonia, further substitution can occur to form secondary or tertiary amines, but the major product is the primary amine.