In algebra, a prime ideal is a subset of a ring that shares many important properties of a prime number in the ring of integers. The prime ideals for the integers are the sets that contain all the multiples of a given prime number, together with the zero ideal.
This generalizes the following property of prime numbers, known as Euclid's lemma: if p is a prime number and if p divides a product ab of two integers, then p divides a or p divides b. We can therefore say
One use of prime ideals occurs in algebraic geometry, where varieties are defined as the zero sets of ideals in polynomial rings. It turns out that the irreducible varieties correspond to prime ideals. In the modern abstract approach, one starts with an arbitrary commutative ring and turns the set of its prime ideals, also called its spectrum, into a topological space and can thus define generalizations of varieties called schemes, which find applications not only in geometry, but also in number theory.
The introduction of prime ideals in algebraic number theory was a major step forward: it was realized that the important property of unique factorisation expressed in the fundamental theorem of arithmetic does not hold in every ring of algebraic integers, but a substitute was found when Richard Dedekind replaced elements by ideals and prime elements by prime ideals; see Dedekind domain.
The notion of a prime ideal can be generalized to noncommutative rings by using the commutative definition "ideal-wise". Wolfgang Krull advanced this idea in 1928. The following content can be found in texts such as Goodearl's  and Lam's. If R is a (possibly noncommutative) ring and P is an ideal in R other than R itself, we say that P is prime if for any two ideals A and B of R:
It can be shown that this definition is equivalent to the commutative one in commutative rings. It is readily verified that if an ideal of a noncommutative ring R satisfies the commutative definition of prime, then it also satisfies the noncommutative version. An ideal P satisfying the commutative definition of prime is sometimes called a completely prime ideal to distinguish it from other merely prime ideals in the ring. Completely prime ideals are prime ideals, but the converse is not true. For example, the zero ideal in the ring of n × n matrices over a field is a prime ideal, but it is not completely prime.
Equivalent formulations of the ideal P ≠ R being prime include the following properties:
Prime ideals in commutative rings are characterized by having multiplicatively closed complements in R, and with slight modification, a similar characterization can be formulated for prime ideals in noncommutative rings. A nonempty subset S ⊆ R is called an m-system if for any a and b in S, there exists r in R such that arb is in S. The following item can then be added to the list of equivalent conditions above:
Prime ideals can frequently be produced as maximal elements of certain collections of ideals. For example: