About three years! I never thought I'd go so long, when I was pregnant with my first, I aimed for at least six months and decided to absolutely forgive myself if I had to use formula. I never expected breastfeeding to be as rewarding and important to both of us as it was. By the time three / four / five / six months had passed, breastfeeding was just so easy for us (there was a learning curve at first, but I didn't have major trouble) and pumping wasn't awful (I work). When we approached a year, there seemed to be no reason to stop - DS wasn't big on solids and my pediatrician happened to mention he was glad we were still breastfeeding, and that may have influenced some, but things were just working and two years, which WHO holds out as the gold standard, seemed like an easy enough target, though I did quit pumping just after a year, and we just nursed when we were around one another. By 20 / 22 months (between 1 1/2 and 2 years of age - forget exactly when), I did make an effort to stop breastfeeding in public - more out of deference to other people's comfort levels with seeing an older baby nursing but also because I was just ready to stop nursing on demand. We did this by just telling my toddler "when we get home you can nurse" or "not yet." He did great with this. Before two years of age, we were down to two nursing sessions, upon wake up and just before bed. Long before two I'd stopped offering, just willingly let him nurse when he wanted to nurse. Sometime around 2.5 years of age, he stopped asking occasionally, and we'd have a few days where he would not nurse at night. (Always wanted it in the morning). Closer to three, we talked about nursing and how he wouldn't do it forever. He asked why, and I told him that nursing was mostly for babies and really small kids. I was also saying this because we were pregnant with my second, and I wanted him to understand that baby got first dibs, because babies NEED to nurse and it was the only food they could eat so they always got to go first, etc. Some people say that in pregnancy your milk dries up, I don't think this happened to us, but still, the talk about babies nursing seemed to impact my son, and one night he said "let's skip the nursing, that's mostly for babies." This was a few weeks after his third birthday. So is said "okay! we'll read an extra story and snuggle up instead." And that's what we did. There were maybe one or two more nights where he asked to nurse after that, which I allowed, and he nursed for like a minute. He seemed to be just reassuring himself that if he really needed it, he wasn't completely cut off. After a few weeks, he was done. So that was about six months ago or so.
I would not change a thing with how it went with that one. I'm not sure I will nurse as long with number two. It all depends on his / her personality, how I'm feeling about it, etc. I can see if my first had been more into solid foods earlier, how we would have started the whole process of gradual weaning a bit sooner. It was important to me to feel like I was responding to his needs, not setting the pace myself, though I realize that I did encourage him to wean (I've read that kids won't really wean on their own until like four years or so!). I didn't want to go that long. I don't judge that one bit, but it wasn't for me. Three was close enough!
I know a lot of people will be squicked out by my story of how long we nursed, and I'm okay with that. I probably would have felt the same way before I had my actual child! So my advice to you OP is to be open to whatever works for you and your child. I'd say that would include supplementing, nursing for a short period of time, or going the long haul. You just never know what will end up working well for your family!
Good luck.