Chavez's return was announced in a series of three messages on his Twitter account, the first of them reading: "We've arrived once again in our Venezuelan homeland. Thank you, my God!! Thank you, beloved nation!! We will continue our treatment here."
They were the first messages to appear on Chavez's Twitter account since Nov. 1.
"I'm clinging to Christ and trusting in my doctors and nurses," Chavez said in another tweet. "Onward toward victory always!! We will live and we will triumph!!"
Vice President Nicolas Maduro said on television that Chavez arrived at 2:30 a.m. and was taken to the Dr. Carlos Arvelo Military Hospital in Caracas, where he will continue his treatment.
Chavez's announced return to Caracas came less than three days after the government released the first photos of the president in more than two months, showing images of him looking bloated and smiling alongside his daughters. The government didn't release any images of Chavez upon his arrival in Caracas.
Maduro said he had accompanied the president on the trip, along with Chavez's daughter Rosa, his brother Adan and National Assembly President Diosdado Cabello.
The vice president said that Chavez has been in a "continuous battle" and that additional details will be provided about his condition later.
Hundreds of Chavez supporters celebrated his return in downtown Caracas, chanting his name and holding photos of the president in Bolivar Plaza. A man holding a megaphone boomed: "Our commander has returned!"
Supporters also celebrated outside the hospital, where a sign atop the building is adorned with a photo of Chavez. They held up a flag and a poster showing the president, and chanted: "We're all Chavez!"
Chavez's precise condition and the sort of cancer treatments he is undergoing remain a mystery, and speculation has grown recently that he may not be able to stay on as president.
Dr. Carlos Castro, scientific director of the Colombian League Against Cancer in Bogota, Colombia, said that given the government's accounts that Chavez is undergoing "complex" treatment, he thinks he likely will have to step down.
"Unfortunately, the cancer he has isn't going to go away, and he's returning to continue his battle. But I think he's conscious that he isn't going to win his fight against cancer, as much as he'd like to win it," Castro told The Associated Press in a telephone interview.
The Venezuelan Constitution says that if a president dies or steps down, a new vote must be called and held within 30 days. Chavez raised that possibility before he left for Cuba in December by saying that if necessary, Maduro should run in a new vote and take his place.
Chavez's return could be used to give a boost to his would-be successor and gain time to "consolidate his alternative leader" ahead of a possible new presidential vote this year, said Luis Vicente Leon, a Venezuelan pollster and political analyst.
Leon told the AP that even if Chavez isn't seen in public, his presence will allow the government to keep up his emotional connection to his followers and rally support.
Even the state newspaper Correo del Orinoco referred to the possibility of a new election in its Monday edition. The top headline, published before Chavez's announced return, said a poll found Maduro would win a possible election.
Many in Cuba were taken by surprise by the news and wondered what it could mean about his health. The island nation depends on Venezuela for a steady flow of oil shipments.
"I hope he's truly getting better, but I doubt it because what he has is irreversible," said Mirta Blanco, a 67-year-old retiree. "Maybe they sent him back to die. I think that's going to be his exit. It's huge news, but I think it's terrible."
In a letter to Chavez that was read on Cuban state TV and radio, retired leader Fidel Castro said he was pleased that Chavez was able to return home.
"You learned much about life, Hugo, during those difficult days of suffering and sacrifice," Castro wrote. "Now that we will no longer have the privilege of receiving news of you every day, we will return to the kind of (written) correspondence we have used for years."
The Venezuelan government didn't explain why Chavez made his surprise return on Monday. Government officials have in recent weeks said that it wasn't clear when the president's medical team would allow him to return to Venezuela, though they had said they hoped it would be soon.
Opposition lawmaker Alfonso Marquina said he thinks Chavez's return must have been in the works for days.
"No one can think that getting on a plane and coming was something that occurred to the president yesterday," Marquina told the AP. "Regrettably, the country was and is the midst of this anxiety, with Venezuelans going from surprise to surprise."
The 58-year-old president hasn't spoken publicly since he left for Cuba on Dec. 10. He underwent his fourth cancer-related surgery on Dec. 11, and the government says that he is now breathing through a tracheal tube that makes talking difficult.
He has been receiving cancer treatment in Cuba on-and-off since June 2011. Chavez has said he has had tumors removed from his pelvic region and has undergone chemotherapy and radiation treatment.
Chavez was re-elected to a new six-year term in October, and his inauguration had been scheduled for Jan. 10 but was indefinitely postponed by lawmakers due to his condition after the surgery, which the government has described as delicate.