U.S. producer prices increased slightly more than expected in June amid gains in the cost of services and motor vehicles, leading to the biggest annual increase in 6-1/2 years.

The Labor Department said on Wednesday its producer price index for final demand climbed 0.3 percent last month also lifted by increases in gasoline prices. The PPI rose 0.5 percent in May. In the 12 months through June, the PPI advanced 3.4 percent, the largest gain since November 2011. Producer prices increased 3.1 percent year-on-year in May.

Economists polled by Reuters had forecast the PPI gaining 0.2 percent in June and rising 3.2 percent year-on-year.

A key gauge of underlying producer price pressures that excludes food, energy and trade services rose 0.3 percent last month. The so-called core PPI edged up 0.1 percent in May.

In the 12 months through June, the core PPI rose 2.7 percent after increasing 2.6 percent in May.

Inflation is gradually rising against the backdrop of a labor market that is viewed as being near or at full employment.

The Federal Reserve's preferred inflation measure, the personal consumption expenditures (PCE) price index excluding food and energy, hit the U.S. central bank's 2 percent target in May for the first time in six years.