How do atmospheres work with a planets gravity field?

No.14135948 ViewReplyOriginalReport
I am at a point where I am simply to ashamed to ask anywhere else.
How does it work with the earths atmosphere and the vacuum of space? How comes, that a air, a gas mixture, with high volume but low mass is attracted to earths gravity field in such large altitudes? At what point is the ionosphere still attached to our planet and at what point it is space? Is there a clear cut? How does it work?