David Beckham and his Galaxy teammates were backed by a zealous jam-packed crowd of 30,510 at the Home Depot Center in Carson, Calif. on Saturday. (Robyn Beck/AFP/Getty Images)

David Beckham’s farewell to a six-year run in MLS came about a minute before the final whistle Sunday, a timely stoppage that allowed the crowd of 30,510 at Home Depot Center to toast the English superstar one last time.

He hugged Landon Donovan and Robbie Keane, his goal-scoring teammates, then reached the sideline and embraced his replacement, Marcelo Sarvas, as well as the coaches.

Beckham had lifted the profile of the ambitious league, endured injury and controversy, and on a gray day marking his last official match in MLS, he departed a champion. A two-time champion, in fact. The Los Angeles Galaxy came from behind in the second half to defeat the Houston Dynamo, 3-1, for a second straight MLS Cup title and fourth overall, tying D.C. United for the league record.

“Twenty years from now,” Galaxy Coach Bruce Arena said, “we are going to look at this league and still talk about David Beckham as the one that helped turn us. For him to walk off the field today with another trophy is amazing. Many would think it was the last chapter. I think David thinks there is another chapter, and if there is, it’s probably going to be a great chapter.”

Describing his thoughts when Arena replaced him, Beckham, 37, smiled and said: “I was tired. I wanted to rest. . . . Win or lose, it was going to be an emotional day.”

Beckham also closed chapters at Manchester United (2003) and Real Madrid (2007) with league titles. During Sunday’s celebration, he brought his three sons to the field and wrapped himself in both the British and U.S. flags.

“We’re certainly going to miss him,” said Keane, the Galaxy’s Irish forward, “but so happy we sent him off with a championship.”

It wasn’t easy. The Dynamo had gone ahead just before halftime on Calen Carr’s goal, but Omar Gonzalez and Donovan scored during a torrent of chances — the 6-foot-5 defender from the University of Maryland on an eight-yard header in the 60th minute and the U.S. World Cup veteran on a penalty kick in the 65th. Keane added a penalty pick during added time.

Gonzalez, who missed the first four months of the season with a knee injury, was a pillar of force on the back line and was voted the match MVP.

It was also a crowning moment for Donovan, who, amid uncertainty about his immediate future, won a fifth MLS crown. The three-time U.S. World Cup starter, 30, has hinted at a leave of absence or perhaps retirement.

“I have to listen to my heart and my gut,” he said, “and right now my gut says to get away for a while.”

Arena was optimistic Donovan would return, saying: “He has still so much to offer. Hopefully with a little bit of rest, he will be ready to get back at some point.”

Donovan should have broken the deadlock in the 13th minute on a clear one-timer from 10 yards — a miss so unfathomable, a confetti cannon launched in premature celebration.

The Dynamo took the lead in the 44th minute, when Carr timed his run succinctly to avoid an offside flag and whistled a rising eight-yarder over Josh Saunders.

Regardless, “We didn’t see any other outcome other than us winning,” Gonzalez said. “We stayed calm and took it to them and it ended up turning our way.”

Carr threatened to extend the lead in the 55th with a six-yard header, but his day soon ended with a leg injury — and the Dynamo’s advantage soon ended under an avalanche of pressure.

The Galaxy drew even when Gonzalez rose above two defenders and headed Juninho’s cross to the far corner from eight yards.

“It felt almost inevitable,” Donovan said. “The second goal was going to come.”

It did on Donovan’s penalty kick — his fifth career MLS Cup goal and 22nd in postseason play. Under severe duress, Ricardo Clark had handled the ball deep in the box, drawing a whistle from referee Silviu Petrescu.

Houston pushed for a late equalizer, but the Galaxy held firm and joined United (1996-’97) and the Dynamo (2006-’07) as MLS’s only repeat champions.

“It's been a successful six years here, and now that we’ve won the second [championship], it’s even more satisfying,” Beckham said. “I just hope people have enjoyed me playing here. It's what I always hope for when I step on the field.”