On a Monday night in March, Jarir Bookstore in downtown Riyadh is bustling. Shoppers test out digital cameras and laptops, while upstairs they flip through paperbacks. At checkout, they can pick up a coloring book and the markers that go with it.

A walk around the back of the building, through unmarked doors and an elevator that smells of cigarettes, leads to corporate headquarters. From there, brothers Muhammad and Abdulkarim Alagil preside as chairman and CEO, respectively, over Jarir Marketing Company. It owns Jarir Bookstore, one of the most recognizable brands in the Gulf.

Alagil, 64, and his four younger brothers have built the company into a giant, selling Arabic and English books, office supplies, and electronics in 41 superstores in four countries, including Kuwait, Qatar, and the U.A.E. Jarir sells roughly half of Saudi Arabia’s laptops and a third of the market’s tablets.

Last year, it earned a net profit of $221 million, an increase of 11.2% from 2014, on $1.7 billion in revenues, also up more than 13%. Jarir made it on FORBES MIDDLE EAST’s ranking of Top 100 Arab Companies for the first time this year at number 67.

Those upbeat numbers though belie a challenging time ahead as Jarir grapples not only with a downturn in consumer spending, which sent sales down more than 25% in the first quarter, but also a realization that the company is behind on a digital strategy. Jarir launched semi-officially an online shopping platform only in January 2016, and less than 1% of its revenues come from web orders.

“We are late on this,” admits Alagil. “It took us a lot of time.”

He attributes the delay to a range of factors: the logistics of e-commerce in the Middle East, which complicate delivery, and the lack of widespread use of secure online payment systems. Alagil says he also tries to be in lockstep with his customers, mostly families with young children, who like to shop on outings. “We saw the market as traditional,” he says. “We were not looking at efficiency.” He confesses to being partial to bricks and mortar, himself. “It’s more fun to be in our store and shop.”

Still, Saudis are among the highest Internet users per capita in the world, and a slew of startups have rushed to take advantage of the exploding e-commerce market. For example, Jordan’s Souq.com has raised a total of $390 million since 2012, reportedly valuing the startup at $1 billion—one-third of Jarir’s market cap. It delivers merchandise in 40 cities throughout the region, and many of its products overlap with Jarir’s.

Jarir is now beta testing a platform to work out the kinks. Currently, it sells online mostly high-ticket items, such as MacBook Pros for $2,600 and GoPro camcorders for $530. Alagil expects to start selling office and school supplies within the next eight to twelve months. Customers are able to look up those items online now, but only to check their availability in stores.

The company has one distribution center ready. Last year, it bought a 200,000 square-foot warehouse in Riyadh to fulfill online orders.

In 2013, it started digitizing books and launched a free application called Jarir Reader, which allows customers to purchase Arabic books at reduced prices (it stocks more than 3,000 titles), and read them on an Android or an Apple mobile device. The app has been downloaded more than 500,000 times. Alagil plans to digitize English books, newspapers and magazines, and make audio versions. The e-books give Jarir the opportunity to sell to Arabic speakers all over the world.

It has the upper hand here. The company has exclusive rights with publishers, including Penguin Random House, Simon & Schuster, and McGraw Hill Education, to translate their titles into Arabic. Classics, such as Jack Kerouac’s On the Road, the management bestseller Good to Great, and Minecraft handbooks, the wildly popular children’s computer game, are available in Arabic.

Alagil had assigned the team in charge of digitizing books, to work simultaneously on the online platform. In hindsight, it was a mistake, because it slowed down implementation. He says they are now in the process of creating separate teams.

Those digital moves are bold for a company that has roots in a tiny shop on Jarir Street in Riyadh.

One of nine children, Alagil grew up in a “traditional home made of mud.” His father was the headmaster of a school for 20 years, before buying a small newsstand in 1974. He sold office and school supplies, Arabic and English books, gifts and greeting cards. His sons helped out, developing a respect for what Alagil calls “products that touch the mind.”

After earning a B.A. in engineering from King Fahd University of Petroleum and Minerals in 1974, and a master’s in civil engineering from the University of California, Berkeley in 1975, Alagil returned to Riyadh in 1976 to join an engineering firm. “I never thought not to go back home,” he says. “I knew there was a boom, and I also thought, I have to make some money.”

After two years, he decided to branch out on his own. He remembered his father as someone who “never kissed a ring,” and who encouraged his sons to avoid government jobs, and be entrepreneurial instead.

When Alagil lived in Berkeley, a chain of office supply superstores called Office Max, left an impression. With business booming in Saudi Arabia, he reckoned there would be a need for papers, pens, stationeries, along with books—essentially what his father sold, but on a grand scale.

His 62-year-old brother Nasser, who has an engineering degree from the University of Colorado, Boulder, helped build the first 15,000 square-foot store in 1979. Brothers Abdullah, 60, Abdulkarim, 57, and Abdulsalam, 50, would also join Muhammad. They called it Jarir, after the Riyadh street location of their father’s newsstand.

“Each one of us was learning something new,” recalls Alagil. They lived in small apartments with their young families and drove beat-up Toyota pickup trucks, putting into the fledgling company around $300,000, raised from savings, and loans from friends and banks.

Abdulkarim dropped out of King Saud University of Petroleum and Minerals to manage the stores. Abdulsalam, who graduated from King Saud University with a degree in finance, oversees the company’s audit committee. Abdullah, a business graduate from the same school, is CEO of the wholesale division.

When they launched a wholesale business in 1980 to sell to government offices and banks, Nasser managed the contracts, supplying “the pens and paper of the Kingdom,” as Alagil puts it. In 1981, he also saw an opportunity to supply furniture to foreign companies establishing headquarters in Riyadh, as well as government offices.

Alagil modeled Jarir after Office Max, increasing the size of their stores to 35,000 square feet, and joined the National Office Product Association in Chicago, a trade organization, to keep up-to-date on the latest concepts.

Even now, he is conservative when it comes to real estate. He buys only when he knows the land will probably appreciate over three to five years. The company owns about a quarter of its 1.5 million square feet of retail space; it has 10 to 20-year leases on the rest.

In 2000, Alagil had a fortuitous meeting with an American friend, who worked for a Saudi bank in New York. Over coffee, he brought up the idea of bringing in outside investors, so that the family could cash out a little. “We thought to harvest some of our hard work,” says Alagil. He sold a 30% stake for about $67 million to Saudi and American investors. Three years later, the brothers took their company public—one of the first families in Saudi Arabia to do so. They now own 43%, recently worth $1.3 billion.

Publicly, Alagil has been consistently bullish on expansion, announcing plans to open five to six stores annually. A recent pitch to investors states that the company expects to have more than 60 stores by 2018.

Bricks and mortar aside, his focus now is clearly on establishing a solid presence online.