The strategy is to first prove $G$ is abelian, then split into two cases based on whether $G$ has an element of order $p^2$.
**Step 1: $G$ is abelian.**
By [Centre of a p-Group Is Nontrivial](/theorems/799), $Z(G) \neq \{e\}$. Since $Z(G) \leq G$ and $|G| = p^2$, [Lagrange's Theorem](/theorems/782) gives $|Z(G)| \in \{p, p^2\}$. Therefore $|G/Z(G)| = p$ or $1$, both of which are cyclic (the former by [Prime Order Implies Cyclic](/theorems/784)). By [Cyclic Quotient by Centre Implies Abelian](/theorems/817), $G$ is abelian.
**Step 2: Case 1 — $G$ has an element of order $p^2$.**
If there exists $g \in G$ with $o(g) = p^2$, then $\langle g \rangle = G$ and $G \cong C_{p^2}$.
**Step 3: Case 2 — every non-identity element has order $p$.**
By [Element Order Divides Group Order](/theorems/783), every non-identity element has order dividing $p^2$, so order $p$ or $p^2$. If no element has order $p^2$, all non-identity elements have order $p$.
Pick $a \neq e$, so $\langle a \rangle \cong C_p$. Pick $b \in G \setminus \langle a \rangle$, so $\langle b \rangle \cong C_p$. We verify the conditions of the [Internal Direct Product Theorem](/theorems/794):
- *Both normal:* Since $G$ is abelian, every subgroup is normal.
- *Trivial intersection:* $\langle a \rangle \cap \langle b \rangle \leq \langle a \rangle$ has order dividing $p$ (by [Lagrange's Theorem](/theorems/782)), so it is $\{e\}$ or $\langle a \rangle$. If $\langle a \rangle \cap \langle b \rangle = \langle a \rangle$, then $\langle a \rangle \subseteq \langle b \rangle$, contradicting $b \notin \langle a \rangle$ (since $|\langle a \rangle| = |\langle b \rangle| = p$). So $\langle a \rangle \cap \langle b \rangle = \{e\}$.
- *Product is $G$:* The element-wise product $\langle a \rangle \langle b \rangle$ has $|\langle a \rangle| \cdot |\langle b \rangle| / |\langle a \rangle \cap \langle b \rangle| = p^2 / 1 = p^2 = |G|$ distinct elements, so $\langle a \rangle \langle b \rangle = G$.
By the [Internal Direct Product Theorem](/theorems/794), $G \cong \langle a \rangle \times \langle b \rangle \cong C_p \times C_p$.