Jim Harbaugh's former quarterback sure outplayed his current one, and it wasn't even close.

Luck passed for 164 yards while facing his college coach for the first time, and the Indianapolis Colts defeated the San Francisco 49ers 27-7 on Sunday.

Trent Richardson scored a 1-yard touchdown on his first carry in his Colts debut after being acquired on Wednesday from the Browns. He was drafted two spots behind top-pick Luck last year.

Ahmad Bradshaw added a 1-yard TD run in the final minutes, and Adam Vinatieri kicked a pair of field goals.

Luck kept coming through again to give Indianapolis (2-1) more opportunities.

"I know he's grinning from ear to ear," Colts coach Chuck Pagano said. "I've never seen him smile the way he was smiling after this one."

This marked Colin Kaepernick's first home loss at Candlestick Park as a starter.

Frank Gore ran for 82 yards after going for 60 total in his first two games, but there were few bright spots for Kaepernick as San Francisco (1-2) struggled to establish a passing game with tight end Vernon Davis sidelined by a hamstring injury. The defense committed numerous costly penalties for the third straight week.

Luck completed his initial six passes and spoiled the home team's reunion day between coaches on both sides who know each other's tendencies dating to their days at Stanford.

The Colts sure appeared to be better prepared.

Luck sent third-year coach Harbaugh to consecutive losses for the first time. He was happier about the fact his two sisters who attend Stanford got to see him play.

"I wasn't caught up in, 'Oh my gosh, I'm going up against Coach Harbaugh, (Greg) Roman and (Vic) Fangio," Luck said. "I figured any time you play this sport, coaches and players come and go so much that you always end up going against someone that you played for or played with or had a good relationship with."

Before Sunday, Harbaugh was 7-0 following a defeat -- and Harbaugh faced criticism for playing and starting Aldon Smith two days after the linebacker was arrested and jailed on suspicion of driving under the influence and marijuana possession.

49ers CEO Jed York said after the game Smith would seek treatment and miss Thursday's game at St. Louis and perhaps be away from the team longer. Smith apologized to "everybody I let down" while acknowledging he has a problem and will fix it.

Kaepernick had been 4-0 on his home field since becoming a starter last November. This time, his 49ers were 10½-point favorites, but looked nothing like the better team in getting thoroughly outplayed.

He completed 2 of his 8 first-half passes and wound up just 13 for 27 for 150 yards with an interception and three sacks.

"There's no one thing, we just didn't execute this offense," Kaepernick said.

The 49ers had six penalties for 48 yards and didn't look much better than they did in their five-turnover, 29-3 loss at division rival Seattle last week.

Kendall Hunter ran for a 13-yard score late in the first quarter, but San Francisco has scored 10 total points the past two games.

Richardson carried 13 times for 35 yards, giving the Colts quite the 1-2 punch with Bradshaw's 19 rushes for 95 yards.

Luck took advantage of a pair of penalties by San Francisco to open Indianapolis' seven-play, 80-yard scoring drive over the opening 3:40 for a 7-0 lead.

On the Colts' first play from scrimmage, safety Donte Whitner received a 15-yard unnecessary roughness penalty when he led with his helmet on a hit against Bradshaw after a 3-yard catch. Tarell Brown was flagged for pass interference on the next play.

Another penalty on Brown, for holding, gave the Colts a first down at the 23 midway through the second quarter and set up Vinatieri's 43-yard field goal. He kicked a 41-yarder in the third quarter.

Brown was penalized yet again for pass interference midway through the fourth.

Luck kept drives going with clutch plays as the Colts won the third straight meeting with San Francisco.

On third-and-9 and throwing from near his end zone late in the third, Luck hit Reggie Wayne for a 25-yard gain in which Wayne broke through several tackle attempts.

All-Pro linebacker Patrick Willis went down on the play and was helped off the field moments later with a groin injury that sidelined him for the rest of the game.

Willis declined to speak to reporters after the game. Harbaugh said he did not know the extent of Willis' injury.

The Colts busted through San Francisco's defensive line, which lost nose tackle Ian Williams to a season-ending ankle injury last week.

"It's one of those games you look back on down the road and say, 'This was a signature win, maybe one that helped you to do great things, that helped you accomplish the program you built,' " Pagano said.

Game notes

49ers special teams standout Bubba Ventrone left after the first quarter with a concussion. ... San Francisco TE Vernon Davis' streak of 98 straight games played was snapped. ... The 49ers had their regular-season winning streak vs. AFC opponents end at five. ... Gore has 2,687 career yards receiving, moving into second place in franchise history for a RB behind Roger Craig (4,442).

Information from ESPN.com's Bill Williamson and The Associated Press was used in this report.