Characterize kernels of monoid homomorphisms 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$.
 A: Let $(M,\cdot,1)$ be a monoid. A submonoid $N$ of $M$ is a kernel of some homorphism if and only if $y_1,..,y_n \in N$, then $x_1y_1...x_ny_n\in N \Leftrightarrow x_1...x_n \in N$. One implication is trivial. For the other we need to generate a congruence from $N$. Let $R$ be the transitive closure of the following set $$S=\{(a,b)\,|\,\exists a_1,...,a_n,b_1,...,b_m \in M, x_1,...,x_n,y_1,...,y_m\in N\ x_1a_1...x_na_n=y_1b_1...y_mb_m,\, a=a_1...a_n,\, b=b_1...b_m\}$$ which is submonoid of $M\times M$ and is reflexive and symmetric. Note that $R$ is hence a congruence. Let $q:M\to M/R$ be the canonical quotient. We will show that $N$ is the kernel of $q$. i.e. we need to show that if $(a,1)$ is $R$, then $a$ is in $N$. Let us begin by showing that if $(a,b)$ is in $S$ and $b$ is in $N$, then $a$ is in $N$. Accordingly suppose there exists $a_1,...,a_n,b_1,...,b_m\in M$, $x_1,...,x_n, y_1,...,y_m\in N$ such that $a=a_1...a_n$, $b=b_1...b_m$ and $x_1a_1...x_na_n=y_1b_1...y_mb_m$. We have $$b=b_1...b_m\in N \Rightarrow x_1a_1...x_na_n=y_1b_1...y_mb_m \in N \Rightarrow a=a_1...a_n \in N.$$ Now suppose that $(a,1)$ is in $R$, then there exists $u_1,...,u_p$ such that $u_1=a$, $u_p=1$ and $(u_i,u_{i+1}) \in S$. We have $(u_{p-1},u_p) \in S$ and $u_p=1$ is in $N$ which implies that $u_{p-1}$ is in $N$. Repeating we find that $a$ is in $N$ as required.
Perhaps it is worth mentioning that when $M$ is commutative the condition above reduces to the one mentioned in the question, and given $N$ the congruence $R$ above is simply $$R=\{(a,b)\,|\,\exists x,y\in N\, xa=yb\}.$$
A: 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.
