Refers to a person in the same class or grade at school. Neutral and widely used.
彼は小学校の同級生です。
He is my elementary school classmate.
同級生と一緒に勉強する。
I study together with my classmates.
He is a classmate of mine from high school.
After I moved, I ended up becoming his classmate.
I met an old classmate at the reunion.
同郷 refers to sharing a hometown or region, whereas 同級生 refers to being in the same class or grade at school, a different kind of shared connection.