Ties are broken as follows:
1) Owners Points
2) Best finishes, most wins, 2nds, 3rds and so on until the tie is broken
3) If tie still remains, then the team with the highest position first breaks the tie
(so if two are ties, both have a win, then the team who won first gets the spot)

From NASCAR Statistics with updates, corrections updated when found out.

NASCAR's Competition Department distributes entry blanks for each race to owners in the series.
Those entries must be returned before the deadline, which is set 13 days in advance of the event.
When the entry is received by Competition, the car is added to the entry list.
There is an inspection fee for each entry.

This is UNOFFICIAL but correct as far as known

If first practice is run, but qualifying is unable to take place, the starting lineup will be based on speeds from the car's fastest lap from the first practice, with top-35 cars in owner points no longer segregated from the non-top 35 cars. Previously, the top 35 cars lined up in front of all other eligible car owners.(NASCAR)(7-7-2011)

What happens if all qualifying gets cancelled [rain/weather/other]?
If bad weather cancels qualifying, the final starting lineup will be determined by practice speeds. The same rule book procedures will be used to determine eligibility to start a race. If weather cancels practice sessions, then the starting lineup will be set by points, per the rule book.

If qualifying AND all practices are cancled, then:If it is during the first 5 races of the season, the previous season OWNERS points are used:
#1) - Previous season Owner Points [position 1-35][team does not have to attempt all the races]
#2) - Race winners from the previous and current season not already in the field
#3) - Past Sprint Cup Champions not in by 1 or 2
#4) - Current season Owner Position [Top 35][not in by rules 1-3]
#5) - Current season race attempts ties broken by current owners position [not in by rules 1-4]
#6) - For 2nd race of season, teams that missed Daytona 500, are seeded in owners points by thier finish in the Duels
#7) - Randon Draw if more then one team with no attempts

If qualifying is cancled by at least one practice gets run, then:If it is the first 5 races of the season, the previous season OWNERS points are used:
#1) - Previous season Owner Points [position 1-35][team does not have to attempt all the races]
#2) - Race winners from the previous and current season not already in the field
#3) - Past Sprint Cup Champions not in by 1 or 2
#4) - Current season Owner Position [Top 35][not in by rules 1-3]
#5) - Current season race attempts ties broken by current owners position [not in by rules 1-4]
#6) - For 2nd race of season, teams that missed Daytona 500, are seeded in owners points by thier finish in the Duels
#7) - Randon Draw if more then one team with no attempts
#8) - One it is determined which teams/driver made the race, then the field is set by 1st practice speeds.

What happens if just qualifying is cancelled?If it is during the first 5 races of the season, the previous season OWNERS points are used:
#1) - Previous season Owner Points [position 1-35][team does not have to attempt all the races]
#2) - Race winners from the previous and current season not already in the field
#3) - Past Sprint Cup Champions not in by 1 or 2
#4) - Current season Owner Position [Top 35][not in by rules 1-3]
#5) - Current season race attempts ties broken by current owners position [not in by rules 1-4]
#6) - For 2nd race of season, teams that missed Daytona 500, are seeded in owners points by thier finish in the Duels
#7) - Randon Draw if more then one team with no attempts
#8) - One it is determined which teams/driver made the race, then the field is set by 1st practice speeds.

What happens if just qualifying is cancelled?AFTER the 5th race of the season, the current season OWNERS points are used:
#1) - First 35 by current Owner Points [team does not have to attempt all the races]
#2) - Last Years Sprint Cup Champ or the Event Champion if not already in the field
#3) - Car Owners whose team has won in the previous and current season not already in the field
#4) - Drivers who have won in the previous and current season not already in the field
#5) - Past Sprint Cup Champions not in by 1 thru 4
#6) - Qualifying Attempts with current Owners points as the tie breaker
#7) - NASCAR will hold a draw for teams with no owners points / attempts
#8) - One it is determined which teams/driver made the race, then the field is set by 1st practice speeds.

NOTE: all above apply as long as the team was entered by the entry deadline - usually 7-13 days before the race

2012 NASCAR Sprint Cup qualifying procedures:
1) qualifying order will be determined by the driver's fastest lap in first practice.
2) times on the speed sheet will be inverted with the slowest cars attempting their qualifying runs first
3) go-or-go-home cars will now qualify among the 35 teams locked in on owner points and not be separated by the field.
4) the NASCAR Sprint Cup director does reserve the right to change a driver's qualifying order or allow "adjustments or repairs" to cars after the car has taken the green flag at the start/finish line.
5) all cars must qualify with a full fuel cell.
6) qualifying consists of two consecutive timed laps (except at road courses, 1 lap)
7) the fastest lap determines qualifying position
8) in case of a rain-out of practice, a random drawing will be held for cars set up in the garage area to determine qualifying order
9) if qualifying is rained out, the order of the field will be set according to Section 9-5 of the 2012 NASCAR Sprint Cup rule book.

Past Champions Provisional Berths in Sprint Cup: A past champion's provisional may be used by an eligible driver a maximum of six times over the course of the NASCAR Sprint Cup Series season. A team with a past champion eligible driver may only use this provisional a maximum of six times during a season. The provisional gives the eligible driver the 43rd and final starting position in the race field. This is only for a team/driver OUTSIDE the top-35 in owners points, drivers whose team is in the top-35 in owners points, would already be guaranteed in the field and not need the Past Champions Provisional
See my 2012 Past Champions Provisional Page for more.