I'd say for the money if you shop smart and really know what you want/what something is worth and what to watch out for, your best
value is to buy used. Buying relatively local you can inspect the bike, test ride it, and perhaps determine how soon you'll need to replace anything that the seller has chosen to avoid investing in but possibly hasn't mentioned to you.
If you want a better guarantee of a trouble-free ride for at least the first year, go new with a hardtail in your price range. You'll sacrifice components at that pricepoint but they'll be new and won't need replacing for some time and any failures should fall back on the manufacturer. One perspective of used vs. new is: Will you be stuck tinkering in the garage more often than riding because you bought a used ride? Or will you be on the trail all the time with a new bike, having few concerns knowing you've got some trickle down from the biggest brand names coming from their best tech that smokes what went into your Trek, as great as it was at the time? Obviously one can never predict what happens the day after you buy a bike much less 6 months later.
Mountain bikes in general require care and maintenance so it's silly to not invest time to learn the basics, unless you always ride with a mechanic carrying a small bike shop on his back. What kind of peace of mind can you live with while riding? I think you're pushing a bit of the boundary for high expectations on a used bike for that amount but there will be exceptions to the rule- there are gems among the average and common findings.
Buying new at that level you're seeing a compromise of sorts in every area. But it really ends up that the components matter the most, assuming no crazy geometry that yields difficult riding regardless of elevation. You may find one brand gives you an above average brakeset, and another brand ups the ante in the drivetrain. Perhaps consider what you may have worn out the fastest (or fought with the most) on your current Trek and aim to find a model that offers a more robust version of that component in its package. Some shops may let you upgrade a component or two for less than retail cost so you walk out with a more robust part X rather than the stock part X.
If you buy used, make a checklist of what to inspect and walk through each item for any bike you test ride. You may not get to test it on a trail, but take it off a curb and make it earn your respect. Buying used and sight unseen can be risky, only you can determine the integrity of the seller. Current pictures are essential- people put pics in their ads of their 5-year old bike from the day they brought it home from the shop. Annoying.
A little background- I have bought 2 used mountain bikes in the past year- one off a bike site classified, the other off eBay. Budget was a bit higher, but overall I received what I expected. Some sellers have to be prodded to get info, others offer it readily. Anyone that acts cagey about questions you ask should probably be removed from consideration. I would buy used again, mostly because I always want to feel like I'm saving some $ by doing so. A future exception would be a closeout of models during an off-season/clearance sale.
Just my opinions. Take what sounds logical to you and disregard the rest.

Good luck in your shopping quest- it's a fun chore!
~Yet another Dave