1. TKTS discount ticket booths.
It's hard to miss these large red ticket booths: situated in the heart of Times Square (under the red steps), on the South Seaport and in downtown Brooklyn. TKTS offers same day tickets for up to 50% off regular prices. Lines can get quite long so plan to head along early (see their website for opening times), and you have to be somewhat flexible in terms of what shows you're willing to see. It's also good to remember that the Times Square booth also offers a 'play only' ticket window which is much shorter than the others.
Helpful hint: Booth #1 at Times Square is a '7 day fast pass' window. This means if you have purchased a TKTS ticket within the previous week you can skip the lines by jumping in this lane (you need to present your ticket stub). This also means that if you're planning on seeing both a play and a musical in the same week, hit up the play first and then the next day you can grab a ticket for the musical without standing in hour+ long queues.
2. Ticket Lottery
Most shows offer a ticket lottery for each night, meaning that you can enter (only one entry per person) and possibly win up to two extra-cheap (usually fantastic) seats for a show. These are typically drawn not long before each show, and it's best to have a mobile number as a form of contact. Each show has slightly different arrangements in terms of their lottery (if they have one) so check out the show's official website for details.
3. Student Rush
Many shows have a student rush policy, meaning that a number of student-discounted tickets are released at a certain time on the day of a performance. Again each show differs so it's a matter of checking their website for details.
If you don't mind waiting around in the foyer of a show, no-show's to as sold out show are actually a pretty fantastic way of scoring a seat. Make yourself known to front of house sales staff, and they'll typically ask you to wait to the side (if there are a few people waiting for tickets you might be asked to stand in a line; hence why it's good to arrive early). If seats are left when the show goes in you may be either offered a cheap price for the ticket, or even enter for free (I've seen two shows for exactly $0!).