Chipotle Mexican Grill reported a quarterly profit that missed Wall Street's view as margins were hurt by higher food prices and legal costs related to a federal probe of illegal immigrant hiring.

Shares in the burrito chain fell 3.5 percent following the announcement.

Restaurant operating margins were 25.8 percent in the quarter, down 110 basis points from a year ago due to food cost inflation, Chipotle said.

General and administrative costs were 7.3 percent of revenue, up 80 basis points from the year earlier. Chipotle said the increase was due to higher non-cash stock-based compensation and higher legal costs.

Chipotle, which warned in May that legal costs connected to government investigations of its hiring of illegal immigrants were rising, said on Tuesday these costs were hurting its margins.

In April, the company revealed that the criminal division of the U.S. Attorney's office for Washington, D.C., had opened an investigation and asked it to turn over documents related to U.S. Immigration and Customs Enforcement audits. In the wake of ICE audits in Minnesota, Virginia and Washington, D.C., Chipotle has fired roughly 500 undocumented workers.

The company also said it booked a loss related to its investment in a failed eatery that was featured in a reality television show on which Chipotle's founder was a judge.

The company took a loss of 5 cents per share related to Chipotle's investment in ANGR Holdings LLC, which operated the restaurants that got money from the television program America's Next Great Restaurant.

Chipotle has been a Wall Street darling because it is building restaurants all over the United States and is breaking into overseas markets like London and Paris. It also has promised to open ShopHouse Southeast Asian Kitchen, a new concept, this summer in the nation's capital.

Analysts have said Chipotle executives have done a stellar job of holding down labor costs -- even as existing restaurants crank out higher sales.

Analysts have been concerned that Chipotle's labor costs could rise as it replaces illegal workers, erasing a cost advantage the company has had over many of its rivals.

But that has not come to pass. Labor costs were 24.3 percent of revenue in the latest quarter, lower than in the previous two quarters.

Still, executives said on a conference call with analysts that the company is seeing higher turnover since its immigration problems became public. Higher turnover can contribute to higher labor costs.

It worries us that we saw turnover increase recently, co-Chief Executive Monty Moran said on the call.

Executives also said the company had encountered no customer resistance to its latest price hikes.

All U.S. restaurant chains are grappling with higher costs for important ingredients like beef, dairy and produce. Unlike many other chains, Chipotle has said it is unable to lock in prices because it uses natural and organic ingredients where possible.

Second-quarter net income at the Denver-based company rose to $50.7 million, or $1.59 per share, from $46.5 million, or $1.46 per share, a year earlier.

The result from the latest quarter missed analysts' average estimate for a profit of $1.68 per share, according to Thomson Reuters I/B/E/S.

Revenue rose 22 percent to $571.6 million. Closely watched sales at restaurants open at least 13 months rose 10 percent, fueled by an increase in customer visits and price hikes to cover higher costs for things like beef, chicken and avocados.

The company raised its full-year outlook for same-restaurant sales but investors appeared to blow that off.

Chipotle's new 2011 forecast calls for a high single-digit to low double-digit percentage increase in sales at established restaurants. It previously said it expected a mid-single-digit percentage increase.

Shares in Chipotle, which hit an all-time high of $333.45 on Tuesday, fell 3.5 percent to $322 in after-hours trading after closing at $333.71.

(Additional reporting by Nichola Groom and Mary Slosson in Los Angeles, editing by Bernard Orr, Gary Hill)