The 20th seed who had never advanced past the quarterfinals in a major before, Costa needed to get past some of the top claycourt players in the world in order to become the third Spanish winner at Roland Garros in the past decade.
In addition to his triumph over Ferrero, a two-time French Open semifinalist, Costa knocked out three-time champion Gustavo Kuerten in the fourth round, rallied from a two-sets-to-one deficit to defeat Guillermo Canas in the quarterfinals and posted a four-set triumph over Alex Corretja, a two-time runner-up.
The 26-year-old Costa won his first title since his triumph at Kitzbuhel in July, 1999. All 12 of his titles have come on clay, putting him second among active players behind Kuerten's 13.
Costa wrapped up his ninth straight win against a countryman in 2 hours, 50 minutes. After his foe double faulted on the second of two match points, he threw his hands up and fell to the court on his back in jubilation.
He embraced Ferrero at the net before joining fiance Cristina Ventura, 14-month-old twin daughters Claudia and Alma and his parents in the stands. Ferrero will get married Friday.
"It is more difficult to speak than to play. I am delighted to have won this trophy," Costa said after he received the winner's trophy from 1977 champion Guillermo Vilas. "I would have never dared dreaming about winning that Grand Slam one day."
With Sunday's triumph, Costa finally stepped out of the shadow of former world No. 1 and 1998 French Open champion Carlos Moya, Corretja and the fast-rising Ferrero.
"Today, I just played great, great tennis," Costa said. "I don't know what happened, but I was playing very good. I was trying, trying, fighting every day. I was preparing to win this tournament. But I didn't believe in myself before.
"These two weeks, I said to myself, 'Don't have bad thoughts and let's try to win the tournament.' That's what I did and I won. The most difficult thing is to believe you can win, and now I am believing."
The third all-Spanish Grand Slam final in history started in inclement weather, and rain halted the match for 25 minutes with the first set tied at 1-1 and Costa serving with a 30-love lead.
Ferrero's shoddy play allowed Costa to go on an 11-game run, taking the first two sets in 49 minutes.
Ferrero looked little like the man who defeated former champion Andre Agassi and second seed Marat Safin in the previous two rounds. One of the pre-tournament favorites, the seventh-seeded Ferrero had 28 unforced through the first two sets, with only five winners -- just one in the opening set.
"I was nothing special in the first two sets. I made a lot of mistakes because I had problems with my body," said Ferrero, who complained of a right ankle sprain sustained before his second-round match and suffered a tear in his stomach muscle in the semifinals against Safin.
"I felt pain in my legs and my abdomin, but I tried to play good throughout the final. But I couldn't play in the first two sets."
The 22-year-old Spaniard finally won a game to start the third set. He hit an ace on game point and raised his arms in mock triumph. The two foes traded breaks afterward and stayed on serve until the 10th game, when Costa hit a forehand drop shot short.
Costa broke serve in the third game of the fourth set when a forehand by Ferrero hit the top of the net and fell back. After holding his own serve, Costa could have added to his lead in the fifth game, but Ferrero saved three break points and snatched serve in the next game as Costa looked tight for the first time during the match.
But Costa shook off the nerves that have plagued him in big moments during his career and converted double-break point with a forehand pass down the line.
After holding his serve at love, Costa gained his first championship point with a cross-court forehand drop volley but hit a forehand long. Ferrero followed with an ace but hit a forehand long and another wide to set up a second match point.
"Today I did the best match of my life. I played unbelievable tennis and I was feeling unbelievable on the court," said Costa, who was playing in his ninth French Open and 26th career major. "I was a little surprised. I thought I was going to be nervous in the final, but I was feeling unbelievable."
With both men junior runner-ups, Costa became the first former boys' finalist to win the men's crown since Thomas Muster in 1985 -- 10 years after finishing second to Jaimie Yzaga in the boys' competition.
After a runner-up finish in 200, Ruano Pascual and Suarez have captured the title here the last two years.
Cara and Wayne Black, the fifth-seeded sister-brother team from Zimbabwe, became the mixed doubles champions, defeating Russia's Elena Bovina and Mark Knowles of the Bahamas, 6-3, 6-3.
In the boys' event, French phenom Richard Gasquet, who took the first set against Costa in the first round of the men's draw, thrashed countryman Laurent Recouderc, 6-0, 6-1, in 45 minutes. The second seed became the youngest player to win at Roland Garros.
Angelique Widjaja lived up to her top seed in the girls' event with a 3-6, 6-1, 6-4 victory over No. 11 American Ashley Harkleroad of the United States.
Widjaja became the first Indonesian player to win here since the junior event began in 1953. She won the girls' crown at Wimbledon last season.
Germans Markus Bayer and Philipp Petzschner claimed the boys' doubles crown while Anna-Lena Groenefeld of Germany and Barbora Strycova of the Czech Republic took the girls' doubles title.