The Scot carded a closing round of 65, which included eight consecutive threes on the back nine, coming home in 28 to shoot up the leaderboard and finish just two shots adrift of home winner Rafa Cabrera Bello.
It completed an excellent week in Madrid for the Livingston golfer having also notched his first hole-in-one as a pro in an opening round 65.
"I'm delighted after not getting off to the best of starts. I managed to knuckle down and I am happy with the result,” Forrest said.
"I hardly hit a shot all day until the 12th where I had a good drive and wedge. Then I knocked it close on 13 and again on 14 for my eagle. On 15 I had a putt from 12 to 15 feet and it was the same on 16. I never gave myself a chance on the front nine but when I eventually did on the back nine I was lucky enough to take them all.
"It's good to be going to Valderrama having put some decent results together. I feel my game is trending in the right direction but I'll need to play a bit better off the tee next week.”
On partnering Rahm, who closed with a 69 to finish six shots off the pace, Forrest added: "That was great. I know Jon from college and playing with the world no.1 in Spain with the crowds going mental was unbelievable."
For victorious Cabrera Bello, challenging for golf's biggest titles is the aim after claiming his first Tour win in four years.
The Spaniard defeated countryman Adri Arnaus on the first play-off hole to lift the trophy and complete a remarkable return to form after claiming just one worldwide top 10 in 2021.
The 37-year-old was undefeated in three matches as a member of Europe's defeated Ryder Cup team in 2016 and a year later won one of the European Tour's elite Rolex Series events at the Scottish Open.
He also finished in the top five at the Open in 2017 and claimed a top 10 at the US PGA Championship in 2018 but arrived in the Spanish capital ranked 231st in the world.
He entered the final round with a two-shot lead and despite seeing that disappear with a double-bogey on the first, he birdied the fourth and then added a hat-trick of gains from the 13th.
He produced a brilliant sand save for par on the last to sign for a 69 and take the contest to extra holes at 19 under.
His tee shot on the second trip up the 18th was not his best, but neither was Arnaus' effort, and Cabrera Bello put an approach to 11 feet and rolled home his birdie putt to take the title.
"I came here in a pretty bad place with scores being not what I expect them to be and to be able to get momentum and turn it around and to walk out of here with a win means a lot to me," he said.
"Hopefully I can keep going and get back to the player I know I can be.”