In Genesis chapter 17, Ishmael is described as being circumcised with Abraham when he is 13 years old:
Genesis 17:25-26
25 And Ishmael his son was thirteen years old, when he was circumcised in the flesh of his foreskin.
26 In the selfsame day was Abraham circumcised, and Ishmael his son.
Yet, later on, in Genesis chapter 21, we see that Ishmael and his mother were cast away from Abraham while he was a "child":
Genesis 21:8-17
8 And the child grew, and was weaned: and Abraham made a great feast the same day that Isaac was weaned.
9 And Sarah saw the son of Hagar the Egyptian, which she had born unto Abraham, mocking.
10 Wherefore she said unto Abraham, Cast out this bondwoman and her son: for the son of this bondwoman shall not be heir with my son, even with Isaac.
11 And the thing was very grievous in Abraham's sight because of his son.
12 And God said unto Abraham, Let it not be grievous in thy sight because of the lad, and because of thy bondwoman; in all that Sarah hath said unto thee, hearken unto her voice; for in Isaac shall thy seed be called.
13 And also of the son of the bondwoman will I make a nation, because he is thy seed.
14 And Abraham rose up early in the morning, and took bread, and a bottle of water, and gave it unto Hagar, putting it on her shoulder, and the child, and sent her away: and she departed, and wandered in the wilderness of Beersheba.
15 And the water was spent in the bottle, and she cast the child under one of the shrubs.
16 And she went, and sat her down over against him a good way off, as it were a bow shot: for she said, Let me not see the death of the child. And she sat over against him, and lift up her voice, and wept.
17 And God heard the voice of the lad; and the angel of God called to Hagar out of heaven, and said unto her, What aileth thee, Hagar? fear not; for God hath heard the voice of the lad where he is.
So, how was Ishmael circumcised by Abraham at age 13, when Abraham cast him and his mother out when he was a child?
To begin, a quick chronology of Ishmael's life up to this point:
So, Ishmael is actually around 15-16 years old in the Genesis 21 account. Isolated from that context, it's very easy to read the account as if Ishmael was an infant. Only Hagar is mentioned as doing anything, and she even places him under a shrub (Genesis 21:15), as if she is a mother placing an infant under a shrub. However, now that we have Ishmael's age in mind, we can see that it's actually the case that she dragged his body under shrubbery after he passed out.
Also, the language used, as mentioned in the introduction, could give the impression that he was an infant, as he is called a "child" (Genesis 21:15-16). However, he is also called a "lad" in the account (Genesis 21:17), which is more indicative of the teenager he was. It's a different Hebrew word, yeh'-led for "child", as opposed to nah'-ar for "lad."
In summary, it's easy to see how someone could get confused by this if they read either passage in isolation, but it is definitely not a contradiction.