Racing for the first time since he retired in a blaze of glory after the 2012 London Olympics with a staggering career total of 18 gold medals, Phelps easily won his morning heat in the 100 metres butterfly then finished runner-up to Lochte in a close final.
Lochte, a five-time Olympic gold medallist who beat Phelps to win the 400m individual medley at London, touched the wall first in 51.93 seconds with Phelps just behind in 52.13.
Unsurprisingly after being out of the water for so long, Phelps was not at his sharpest. Of the eight finalists, he was the slowest to get off the blocks then mistimed his touch on the first wall but said he was happy with his return.
"I never like to lose but I did what I wanted to do, I wanted to be around 1:52," Phelps said.
"Apart from what was literally the worst turn of my career, I think I did pretty well. It was fun."
Phelps' time was well outside the world record of 49.82 he set at the 2009 world championships but still safely under the qualifying standard for the U.S. national championships in August, which double as the selection event for next year's world titles in Russia.
Although the 28-year-old still holds the world record in three individual events, none of his past times count for future competitions because they were recorded before the qualifying period began in June 2013.
The last time Phelps needed to post a time to qualify for the national was when he was 13.
Phelps and his coach Bob Bowman were both reluctant to talk about their long-term goals but neither has ruled out the possibility of competing at the 2016 Rio Olympics.
"I could tell when he came in and I first saw him warm up that it was going to be good, that he was feeling good and he was into it," Bowman said after the heats.
"I'm just glad he came out of the race and he's got one under his belt.
"He's qualified for nationals so let's see what's down the road. He has an opportunity if he wants to take advantage of it."
Unshaven and still 7 pounds (3 kg) over his ideal racing weight, Phelps was a model of composure in the morning heats, chatting and joking with his competitors and uncharacteristically smiling to the crowds, which included his mother.
But he looked more like his previous incarnation when he arrived for the evening final, climbing the starting blocks with the glazed look of a prize fighter determined to win.
"I felt like a summer league swimmer today. I was just so excited. I felt like I should have my lane and heat written on my hand in case I forget it.
"I didn't want to wait any more. I didn't want to sit on the massage table any more. I wanted to get this first race done."
Lochte is also in the early stages of a comeback from a knee injury that kept him out of the pool late last year.
He said he thought of quitting the sport but the return of Phelps has given him a new lease of life as he posted the second fastest time in the world this year for the 100 fly.
"I probably wouldn't have gone that time if Phelps wasn't in the pool with me," he said.
"I'm glad he's back. Me and him, we push each other all the time. What he's done for the sport of swimming and him leaving, it kind of broke my heart a little because I love getting the blocks and racing him.
"Racing against him is so much fun, it's a challenge but I love it and now that's he back, I've got a big old smile."
Tickets for the event sold out within hours after Phelps confirmed he was making his comeback and were selling for more than six times their face value on the secondary market.
More than 100 media - a 500 percent increase on last year's meet - descended on the Skyline Aquatic Center to see him take his first plunge back into the water.
Even before his race, the crowd lining the warm-up pool was five deep with people trying to snap a picture of him practicing with his kickboard while a television helicopter buzzed above the pool.
Gregg Troy, who was previously the personal coach of Lochte and the head coach of the U.S. men's team at the London Olympics, said it was great for the sport to see Phelps back.
"He's the best. It's that simple," Troy told Reuters.
"He's capable of doing anything he decide he wants to do. He's actually at the prime age for males, he's not over the hill by any means."
Phelps had planned to swim in three events at his comeback meet but ditched the 100m freestyle to focus on the 100m butterfly and Friday's 50m freestyle and despite his loss, he said he was just glad to be back at all.
"This is the sport I have known all my entire life and it's the sport I love the most," he said. "When you hear the roar in the stands, it's a pretty amazing feeling.
"I'm just a 28-year-old man stepping up on the blocks and having fun again."
- Sports & Recreation
- Swimming & Diving