Melbourne (CNN) If this was the final match of Andy Murray's career, the Briton made sure his swansong was a memorable one -- losing a four-hour, five-set thriller to Roberto Bautista Agut in Melbourne.

Beset by a troubled hip, the three-time grand slam winner announced Friday he would be quitting the sport this year because of the pain he experiences.

But after his first-round loss Murray, who has tumbled to 229 in the world rankings after 18 months troubled by injury, opened the door to a possible return to Australia by saying he would "do everything possible" to play again in a tournament he has never won.

Murray seemed on course for a sharp exit Monday when he fell two sets behind to the dogged Spaniard, but the 31-year-old defied the pain and roused the Melbourne crowd with an extraordinary comeback to take the match into a deciding fifth set before suffering a heroic 6-4 6-4 6-7 (5-7) 6-7 (4-7) 6-2 loss.

Battling back in the third and fourth sets took its toll on the Scot as Bautista Agut broke with ease twice in the final set to secure the first victory of his career over Murray. Indeed, the Spaniard had previously never won a set against the former world No.1.

"If I want to go again, I'll need to have a big operation, which there's no guarantee I'll be able to come back from anyway, but I'll give it my best shot," he said.

"If I want to go again, I'll need to have a big operation, which there's no guarantee I'll be able to come back from anyway, but I'll give it my best shot," he said.

After his first-round loss Murray the Briton opened the door to a possible return to Australia by saying he would "do everything possible" to play again in a tournament he has never won.

After his first-round loss Murray the Briton opened the door to a possible return to Australia by saying he would "do everything possible" to play again in a tournament he has never won.

Battling back in the third and fourth sets took its toll on the Scot as Bautista Agut broke with ease twice in the final set to secure the first victory of his career over Murray.

Battling back in the third and fourth sets took its toll on the Scot as Bautista Agut broke with ease twice in the final set to secure the first victory of his career over Murray.

But the 31-year-old defied the pain and roused the Melbourne crowd with an extraordinary comeback to take the match into a deciding fifth set.

But the 31-year-old defied the pain and roused the Melbourne crowd with an extraordinary comeback to take the match into a deciding fifth set.

The Briton has tumbled to 229 in the world rankings after 18 months troubled by injury and seemed on course for a sharp exit in Melbourne.

The Briton has tumbled to 229 in the world rankings after 18 months troubled by injury and seemed on course for a sharp exit in Melbourne.

However, it was Roberto Bautista Agut who made the better start, confidently taking a two set lead against the ailing Murray.

However, it was Roberto Bautista Agut who made the better start, confidently taking a two set lead against the ailing Murray.

The vast majority of fans inside the Melbourne Arena for Murray's first round match against Roberto Bautista Agut were cheering the three-time grand slam champion.

The vast majority of fans inside the Melbourne Arena for Murray's first round match against Roberto Bautista Agut were cheering the three-time grand slam champion.

Beset by a troubled hip, Murray announced Friday he would be quitting the sport this year because of the pain he experiences.

Not done yet?

An ailing Murray said Friday he wanted to say farewell in July at Wimbledon -- where he made history in 2013 by ending Britain's 77-year men's drought.

However, speaking to on-court interviewer Mark Petchey -- one of his first coaches -- after Monday's marathon, Murray did not rule out playing at the Australian Open again but during the post-match press conference he further explained he had two options.

For Murray to return to Melbourne, he said he would need another major operation on his right hip and even then there would be no guarantee that he'd be able to compete at the level he has been accustomed to over the last decade. He said he'd make a decision "probably in the next week or so."

JUST WATCHED Roger Federer muses on retirement planning Replay More Videos ... MUST WATCH Roger Federer muses on retirement planning 03:18

"One is to take the next four and a half months off, then build up, play Wimbledon," he said. "I mean, I'm really struggling. I can't walk properly at all just now."

He continued: "Having an operation like that, there's absolutely no guarantees I'd be able to play again. I'm fully aware of that. It's a really big operation.

"But there is the possibility, because guys have done it before. Bob Bryan is doing it just now," he added, referring to the legendary doubles specialist. "Some other athletes have given it a go. But, like I said, there's no guarantees. That's kind of the decision I have to make, that possibility of not having one more match by having the operation

"If I go ahead with the operation, I don't recover well from it, then I don't play again. I'm aware of that. That is the decision that I have to make.

"It will improve my quality of life, I'll be in less pain doing just normal things like walking around and putting your shoes and socks on.

"If today [Monday] was my last match, it was a brilliant way to finish. That's something that I'll probably take into consideration.

"It was an amazing atmosphere. I literally gave everything that I had on the court, fought as best as I could, and performed a lot better than what I should have done without the amount I've been able to practice and train. I'd be okay with that being my last match."

If the five-time tournament finalist does happen to return in Melbourne, a video tribute featuring his fellow "Big Four" members of Roger Federer, Rafael Nadal and Novak Djokovic, plus the likes of former world No. 1s Caroline Wozniacki and Karolina Pliskova would prove to be a little premature. Only time will tell.

"You've done Scotland proud, you've done Britain proud, you're a Sir. Who can say that?" Federer said in the tribute, referring to Murray receiving a knighthood in 2016.

Djokovic, the man beaten by Murray in the 2013 Wimbledon final, added: "Thank you always for leaving your heart and every last drop of energy on the court."

Early worries for Murray

Few would have forecast this first-round encounter extending to four hours and nine minutes when Bautista Agut took a two-set lead in a tussle Murray described as "incredible."

Murray has lost five Australian Open finals

Physically, there were initial signs of improvement in his condition against Bautista Agut.

Bautista Agut, though, did beat childhood pal and world No. 1 Djokovic en route to winning his ninth title this month in Doha.

In a tightly contested first set where the Scot struggled with his first-serve percentage, Bautista Agut broke for 5-4 after saving a break point in the previous game.

The second set finished with the same score with Murray beginning to visibly struggle. He was not getting lift on his ground strokes, which resulted in a flurry of errors into the net.

Murray, however, had something to cheer about -- as did the overwhelming majority of fans supporting him on Melbourne Arena -- when he showed off his great coverage by poking a backhand winner off an angled Bautista Agut backhand to break for 2-2 in the third.

It was a key point that turned around the affair.

Murray congratulates Bautista Agut, who beat him for the first time in his career

The Briton erupted, and the crowd -- which included the Scot's mum Judy and brother Jamie -- gave him a standing ovation. Murray's second wind had energized everyone on what was a stifling day.

Murray pumped his fist when saving a break chance at 4-4 with a backhand down the line and even manufactured a set point at 5-4. After erring on a forehand following a lengthy exchange, the crowd groaned but he got the job done in the tiebreak, helped considerably by his serve.

While his first serve percentage fluctuated, Murray hit 19 aces in the match.

In the fourth set, the Murray comeback continued. At 5-4, Bautista Agut was a game away from progressing to the second round but a hold to love from the two-time Wimbledon champion leveled matters and a tiebreak was needed to decide the outcome.

Forces a fifth

Murray raced into a 4-1 lead and held on, roaring loudly as he remarkably came out on top of yet another tiebreak. But he faltered in the fifth and though he saved match point, he was clearly struggling after giving so much in leveling the match.

At 1-5 he waved to the crowd and appeared close to tears while serving.

JUST WATCHED Tearful Roger Federer remembers late coach Replay More Videos ... MUST WATCH Tearful Roger Federer remembers late coach 03:21

He then temporarily extended the clash by saving a match point with a short volley in a great rally to keep himself and the crowd going.

But on his second match point, Bautista Agut ripped a forehand down the line to force an error.

"Well today was an incredible night," said Bautista Agut, now 3-20 against the so-called "Big Four".

"Andy deserves the atmosphere here and all the people who came to watch him," added the 30-year-old, who will have most of the crowd against him again in the second round since he faces Australian John Millman.

"I want to congratulate him for all he did for tennis."

There may still be more to come from Murray but if this is the end it was a fitting finale to Murray's gritty, historic career.