The palace stated that the infection arose from "a pre-existing condition".
The Duke of Edinburgh, who is to retire from public duties later this year, was admitted to King Edward VII Hospital in London on Tuesday night.
He has been in and out of the hospital in recent years for treatment for a heart condition.
The Palace said that the prince would not be attending the so-called Queen's Speech Wednesday, a largely ceremonial address in which the queen reads out the government's lawmaking priorities for the next two years. The Palace said he is in good spirits and added that Prince Charles would accompany his mother to Parliament in his father's stead.