McDonald's is offering free coffee to its customers for a limited time as competition for the breakfast crowd intensifies. The world's biggest hamburger chain announced Friday that participating U.S. locations will offer small cups of McCafe coffee at no charge during breakfast hours from March 31 through April 13. McDonald's said that this is the first time it's ever had a free coffee event nationwide. Its McCafe product line, which also includes iced coffees and other drinks, debuted in the U.S. in 2009.

Emile Wamsteker | Bloomberg | Getty Images

The Oak Brook, Ill., company is hoping that the coffee giveaway will bring in new customers. It's also a way to get existing customers to come in more frequently. And it's likely that those stopping by for a free coffee will be tempted to pick up a breakfast sandwich or other items while there.

Read MoreHow to get the best caffeine buzz for your buck Breakfast is an important component of McDonald's business, comprising about 20 percent of its U.S. sales. The announcement comes as Taco Bell rolls out ads to promote its new breakfast menu, which includes a waffle taco. The ads star everyday men that happen to be named Ronald McDonald, the same name as McDonald's mascot. Chains like McDonald's, Taco Bell and Starbucks—which recently revamped its sandwiches—are all fighting for a piece of the breakfast market because people are increasingly buying breakfast on the go.

McDonald's coffee giveaway comes shortly after it reported that an important sales figure declined 1.4 percent at established U.S. locations in February. The chain blamed bad winter weather but also said that "challenging industry dynamics" played a role. The company has worked on adapting by making menu changes such as giving an option for egg whites in breakfast sandwiches and adding chicken McWraps to help appeal to those looking for fresher, healthier food. For a long time McDonald's, which started offering breakfast nationally in 1975 with the roll out of the Egg McMuffin, has dominated the morning category. Rival Burger King came out with their breakfast menu in 1979 and others have followed. The latest is Taco Bell, which launched its new breakfast menu on Thursday.

