Lowe's is challenging rival Home Depot for a customer the smaller home improvement chain has admittedly not paid much attention to over the years: the professional contractor.

Lowe's new strategy catering to so-called pros is one of the things the retailer credits with beating Home Depot on its sales growth during the second quarter.

"I think one of the strategic missteps over the last seven years here is not really understanding what the pro customer does to the overall productivity of the business," said Joseph McFarland, executive vice president of stores.

Lowe's said the company added 35,000 new pro customers in this quarter alone, although it wouldn't disclose the total number of customers for competitive reasons. Home Depot announced it had reached 1 million pro customers this quarter.

Sales at Lowe's U.S. locations open for at least a year rose by 3.2% during the second quarter, compared with a 3.1% rise in same-store sales at Home Depot's U.S. stores. Lowe's earnings growth also beat out its larger competitor. The smaller retailer's second-quarter profit of $1.67 billion jumped 10.2% from the same time last year. Home Depot's $3.48 billion profit, by comparison, fell by 0.8% from last year, according to data compiled by FactSet.

"We're pretty confident that our sales momentum over the last two quarters, our improvement in transactions, and our improvement in sales per square foot in large part is driven by pro," said McFarland. "So the strategic rationale for pro is traffic, transaction, sales per square foot productivity and just unlocking more value in every location."

Sales to professional contractors outpaced sales to do-it-yourself customers for both companies during the second quarter. But both still have a long way to go.

"Both Home Depot and Lowe's have recognized that as they think about the addressable market, they are under-penetrated in the professional customer," said Oppenheimer analyst Brian Nagel. "So they both have made these pushes now to go more aggressively for the professional customer. And that's been an ongoing narrative in the last several quarters."

Nagel said Home Depot, which he believes has historically been managed better, is further along the journey of capturing pros. But to make sure its customers don't jump ship, Home Depot is continuing to "invest in a portfolio of service offerings to deepen our level of engagement with the pro."

It launched a business-to-business website for pros, and said it's working to simplify shopping experiences and delivery for the professional customers. It's also beefing up its tool rental service.

"Twenty-five percent of the pros rent from us today," said Craig Menear, CEO of Home Depot in an earnings call. "We know that 90% of pros rent tools, so we have an opportunity as we invest in this business to continue to grow."

Lowe's is investing in large quantities of supplies, to make sure there's enough in stock for contractors. It's also giving pros special treatment, with preferring parking at its stores, dedicated associates at pro desks and dedicated supervisors for pro areas. These are services Home Depot has already rolled out.

Another area that the two competitors are eyeing are paints, which Lowe's said are the most popular product for DIY projects. Home Depot is creating Color Solution Centers in its physical locations to simplify the color selection process for customers, and has launched a new Project Color app. But Lowe's said that for the first time in 10 years, paint sales led the company's merchandising department grow.

According to Nagel, that's because Lowe's has smartened up its paint promotions.

"Under prior management, Lowe's would do these broad-based promotions and those aren't as effective as a marketing tool to garner customers," he said. "One of the areas they identified is if they can do targeted price promotions on paint, that helps to drive the overall business."