In the quarter, we delivered comparable store sales growth of 5.8% and adjusted operating income margin of 11.4%, an increase of 11 basis points versus 2020.
On a two-year stack, our comp sales improved 13.3% and margins expanded 227 basis points compared to Q2 2019.
Adjusted diluted earnings per share of $3.40 increased 15.3% compared to Q2 2020 and 56.7% compared to 2019.
Year-to-date, free cash flow more than doubled, which led to a higher than anticipated return of cash to shareholders in the first half of the year, returning $661.4 [Phonetic] million through a combination of share repurchases and quarterly cash dividends.
Finally, we're pleased that through the first half of the year, we added 28 net new independent Carquest stores.
We also announced the planned conversion of an additional 29 locations in the West as Baxter Auto Parts joins the Carquest family.
In Q2, our VIP membership grew by 8% and our Elite members representing the highest tier of customer spend, increased 21%.
Shifting to operating income, we expanded margin in the quarter on top of significant margin expansion in Q2 2020.
In Q2, we converted nearly 150 additional stores and remain on track with the completion of the originally planned stores by the end of Q3 2021.
Our team delivered sales per store improvement and we remain on track to reach our goal of $1.8 million average sales per store within our timeline.
In the first half of the year, we opened six Worldpac branches, 12 Advance and Carquest stores and added 28 net new Carquest independents, as discussed earlier.
We also announced the planned conversion of 109 Pep Boys locations in California.
Our total recordable injury rate decreased 19% compared to Q2 2020 and 36% compared to Q2 2019.
In Q2, our net sales increased 5.9% to $2.6 billion.
Adjusted gross profit margin expanded 239 basis points to 46.4%, primarily as a result of the ongoing execution of our category management initiatives, including strategic sourcing, strategic pricing and own brand expansion.
In the quarter, same SKU inflation was approximately 2% and we expect this will increase through the balance of the year.
Year-to-date, gross margin improved 156 basis points compared to the first half of 2020.
As anticipated, Q2 adjusted SG&A expenses increased year-over-year and were up $109 million versus 2020.
This deleveraged 228 basis points and was a result of three primary factors.
These increases in Q2 were partially offset by a decrease in COVID-19 related expenses to approximately $4 million compared to $15 million in the prior year.
As a result of these factors, our SG&A expenses increased 13.3% to $926.4 million.
As a percent of net sales, our SG&A was 35% compared to 32.7% in the prior year quarter.
Year-to-date, SG&A as a percent of net sales improved 88 basis points compared to the first half of 2020.
Our adjusted operating income increased to $302 million compared to $282 million one year ago.
On a rate basis, our adjusted OI margin expanded by 11 basis points to 11.4%.
Finally, our adjusted diluted earnings per share increased 15.3% to $3.40 compared to $2.95 in Q2 of 2020.
Our free cash flow for the first half of the year was $646.6 million, an increase of $338.4 million compared to last year.
Our capital spending was $58.7 million for the quarter and $129.6 million year to-date.
And in line with our guidance, we estimate we will spend between $300 million and $350 million in 2021.
Due to favorable market conditions along with our improved free cash flow in Q2, we returned nearly $458 million to our shareholders through the repurchase of 2 million shares at an average price of $197.52 and our recently increased quarterly cash dividend of $1 per share.
Based on all these factors, we are increasing our full year 2021 guidance ranges, including net sales in the range of $10.6 billion to $10.8 billion, comparable store sales of 6% to 8% and adjusted operating income margin of 9.2% to 9.4%.
As a result, we're lowering our guidance range and now expect to open 80 to 120 new stores this year.
Additionally, given the improvement of our free cash flow and our accelerated share repurchases in the first half of the year, we are also increasing our guidance for free cash flow to a minimum of $700 million and an expected range for share repurchases of $700 million to $900 million.

Summary:
In the quarter, we delivered comparable store sales growth of 5.8% and adjusted operating income margin of 11.4%, an increase of 11 basis points versus 2020.
Adjusted diluted earnings per share of $3.40 increased 15.3% compared to Q2 2020 and 56.7% compared to 2019.
Shifting to operating income, we expanded margin in the quarter on top of significant margin expansion in Q2 2020.
In Q2, our net sales increased 5.9% to $2.6 billion.
Finally, our adjusted diluted earnings per share increased 15.3% to $3.40 compared to $2.95 in Q2 of 2020.