The 87-year-old Nobel laureate entered the hospital Monday suffering from the infection and from dehydration, Mexico's Secretary of Health said in a written statement.
"The patient has responded to treatment. Once he's completed his course of antibiotics his discharge from the hospital will be evaluated," the statement said.
The author's son Gonzalo said there had been no medical emergency and he expected his father to leave the hospital early next week.
"He went to a normal room," the son said. "He was never in the emergency room."
Garcia Marquez has lived in Mexico City for more than three decades, and has limited his public appearances in recent years.
He was feted before the press on his birthday last month by friends and well-wishers who brought him cake and flowers outside his home in an exclusive neighborhood in the south of Mexico City. He did not speak at the event.
Garcia Marquez's friend Elena Poniatowska, a renowned Mexican journalist and author, said she had last seen him when he visited her home in November with a bouquet of yellow roses, a symbol that made frequent appearances in his epic, hallucinatory novel "One Hundred Years of Solitude."
"He looked well," Poniatowska told The Associated Press.
Garcia Marquez's hospitalization did not appear related to longstanding reports about the author's memory problems, which have not been publicly diagnosed. A person close to the family said that Garcia Marquez can carry on with normal life, although he has good days and bad days.
"He functions well in daily life," said the man, who did not want to be quoted by name out of respect for the family's desire to keep the issue out of the spotlight.
Garcia Marquez is by many accounts the Spanish language's most popular writer since Miguel de Cervantes in the 17th century. His extraordinary literary celebrity has drawn comparisons with Mark Twain and Charles Dickens.
"One Hundred Years of Solitude" has sold some 50 million copies in more than 25 languages and its 1967 publication was a milestone in a two-decade-long Latin American literature boom.
Other contemporary classics by the man with the bushy black eyebrows and white mustache, known to friends as "Gabo," include "Chronicle of a Death Foretold," ''Love in the Time of Cholera," ''The General in His Labyrinth" and "Autumn of the Patriarch."
Garcia Marquez won the Nobel Prize for literature in 1982, and his books have outsold everything published in Spanish except the Bible. Along with writers including Norman Mailer and Tom Wolfe, he was also an early practitioner of literary nonfiction that would become known as New Journalism.
Take ABC13 with you!
Download our free apps for iPhone, iPad and Android devices