How to directly prove that $M$ is maximal ideal of $A$ iff $A/M$ is a field?

An ideal $M$ of a commutative ring $A$ (with unity) is maximal iff $A/M$ is a field.

This is easy with the correspondence of ideals of $A/I$ with ideals of $A$ containing $I$, but how can you prove it directly? Take $x + M \in A/M$. How can you construct $y + M \in A/M$ such that $xy - 1 \in M$? All I can deduce from the maximality of $M$ is that $(M,x) = A$.


From $(M,x)=A$ you can infer that there are $m\in M, y\in A$ so that $m+xy=1$. Thus, $xy+M=1+M$.


I don't think anyone has mentioned the converse yet so I'll post it here.

Converse: If $A/M$ is a field then $M$ is a maximal ideal of $A$.

Proof: Suppose there exists an ideal $I$ of $A$ such that $M \subsetneqq I \subsetneqq A$. Then this means that there is an $x \in I$ such that $x \notin M$. Now because $A/M$ is a field, this means $\exists y \in A \backslash M$ such that

$$xy \equiv 1 \operatorname{mod} M.$$

Equivalently this is saying that $xy - 1 = m$ for some $m \in M$. Rearranging the equation we get that $xy - m = 1$. But then as $M \subsetneqq I$ this means that $m$ is necessarily contained in $I$ too. Since $I$ is an ideal this means that $1 \in I$ which is a contradiction since $I$ was assumed not to be the whole ring.