TITLE: Characterize kernels of monoid homomorphisms
QUESTION [9 upvotes]: The kernel of a monoid homomorphism $f : M \to M'$ is the submonoid $\{m \in M : f(m)=1\}$. (This should not be confused with the kernel pair, which is often also named the kernel.)
Question. Which submonoids $N$ of a given monoid $M$ arise as the kernel of a monoid homomorphism? (If necessary, let us assume that $M$ is commutative.)
Here is a necessary condition: If $xy \in N$, then $x \in N \Leftrightarrow y \in N$.

REPLY [5 votes]: A late answer. 
Nex's answer is correct, but can be simplified as follows.
Let $N$ be a submonoid of $M$. Then there exists a congruence $\sim$ on $M$ such that $N = [1]_\sim$ if and only if, 
$$
  \text{(C) for all $x,y \in M$ and for all $u \in N$, $xuy \in N \iff xy\in N$.}
$$
Condition (C) is necessary since $u \sim 1$ implies $xuy \sim xy$. To prove it is sufficient, consider the syntactic congruence of $N$, which is the congruence $\sim_N$ on $M$ defined by $u \sim_N v$ if and only if, for all $x, y \in M$,
$$
  xuy \in N \iff xvy \in N
$$
Condition (C) just says that $[1]_{\sim_N} = N$, which concludes the proof.
A side remark. The term kernel should probably be reserved to the kernel category of a monoid homomorphism. See the papers [1, 2, 3] for references and these slides for a quick overview.
[1] S. Margolis and J.-É. Pin, Inverse semigroups and extensions of groups by semilattices, J. of Algebra 110 (1987), 277-297.
[2] B. Tilson, Categories as algebra: an essential ingredient in the theory of monoids, J. Pure Appl. Algebra 48 (1987), no. 1-2, 83--198.
[3] B. Steinberg and B. Tilson, Categories as algebra II, Internat. J. Algebra Comput. 13 (2003), no. 6, 627--703.