Guildford is the county town of Surrey, it has a cathedral and a university and it is probably the largest town in the county of Surrey (with Woking perhaps catching it up). Despite all of this, however, Guildford is not a city.
It is often believed that a place can be called a city if it has a cathedral, but this is, technically speaking, not so. The link between city status and a cathedral dates back to the 16th century when Henry VIII granted city status to a small number of towns with a diocesan cathedral. This explains why tiny places such as St David's in Wales (population around 2,000) are cities, and why Guildford is not (Guildford's cathedral was built in the 20th century, and before that Guildford was in the diocese of Winchester, which is a city). Nowadays the monarch can grant city status to any town -- not that it confers any particular privileges or benefits.
The Guildford Summer Festival is going on at the moment and I went on a guided walk through old parts of the town yesterday evening. The guide told us that Guildford was given a charter allowing it to hold a market in the 13th century, and at the time settlements which had cornmarkets and the like were allowed to call themselves towns. These days the distinction between towns and villages is very vague -- some so-called villages are much larger than so-called towns -- but the OED does make reference to the fact that the term 'market town' arose as a result of fairs or markets held in some settlements and not others.
By the way, before I go on, I must emphasise that all of the information in this post about towns, cities and boroughs refers only to England and Wales. The situation and definitions in Scotland and Northern Ireland are completely different.
Guildford is a town, not a city, but it is also a borough, a term that does not apply to every town. Borough status is granted to a local government district (in England and Wales) by the monarch. Most of today's boroughs were given the status in the local government reforms of the 1970s and 1980s, but the use of the term 'borough' goes back centuries (eg Lymington and Wigan are referred to as boroughs in two OED citations from the 16th century). Earlier meanings of borough were fortress, fortified town and manor house.